Regular Expression Basic Syntax Reference

Posted on Agustus 7, 2008. Filed under: Tutorial Programming | Tag:, , , , , |

Characters
Character Description Example
Any character except [\^$.|?*+() All characters except the listed special characters match a single instance of themselves. { and } are literal characters, unless they’re part of a valid regular expression token (e.g. the {n} quantifier). a matches a
\ (backslash) followed by any of [\^$.|?*+(){} A backslash escapes special characters to suppress their special meaning. \+ matches +
\Q...\E Matches the characters between \Q and \E literally, suppressing the meaning of special characters. \Q+-*/\E matches +-*/
\xFF where FF are 2 hexadecimal digits Matches the character with the specified ASCII/ANSI value, which depends on the code page used. Can be used in character classes. \xA9 matches © when using the Latin-1 code page.
\n, \r and \t Match an LF character, CR character and a tab character respectively. Can be used in character classes. \r\n matches a DOS/Windows CRLF line break.
\a, \e, \f and \v Match a bell character (\x07), escape character (\x1B), form feed (\x0C) and vertical tab (\x0B) respectively. Can be used in character classes.
\cA through \cZ Match an ASCII character Control+A through Control+Z, equivalent to \x01 through \x1A. Can be used in character classes. \cM\cJ matches a DOS/Windows CRLF line break.
(lebih…)
Iklan
Baca Pos Lengkap | Make a Comment ( None so far )

Liked it here?
Why not try sites on the blogroll...