Large Text File Viewer 4.1 - Regular Expression Syntax
|
Special Symbol |
Meaning |
| _ | Any white-space character (including tab). |
| . | Any single character. |
| [aeiou] | Any single character that is contained in the brackets. For example, 'b[aei]d' matches 'bad', 'bed', and 'bid'. |
| [^aeiou] | Any single character that is NOT contained in the brackets. For example, 'b[^aei]d' matches 'bxd', 'b3d', 'b_d', and so on, but not 'bad', 'bed' and 'bid'. |
| [a-z] | Any single character that is in the range of characters separated by a hyphen (-) in the brackets. For example, 'x[0-9]' matches 'x0', 'x1', 'x2', and so on. |
| [^a-z] | Any single character that is NOT in the range of characters separated by a hyphen (-) in the brackets. For example, 'x[^0-9]' matches 'xa', 'xb', 'xc', and so on, but not 'x0', 'x1', 'x2', and so on. |
| ~ | Any single character as long as it is different from the following character. For example, 'b~ad' matches 'bd', 'bed', 'b2d', and so on, but not 'bad'. |
| ^ | The beginning of a line. |
| $ | The end of a line. |
| \ | Quote the following character. For example, '100$' matches '100' at the end of a line, but '100\$' matches the string '100$' anywhere in a line. |
| * | None or more of the preceding character or expression. For example, 'ba*d' matches 'bd', 'bad', 'baad', 'baaad', and so on. |
| + | At least one or more of the preceding character or expression. For example, 'ba+d' matches 'bad', 'baad', 'baaad', and so on, but not 'bd'. |
| ? | None or one of the preceding character or expression. For example, 'ba?d' matches 'bd' and 'bad', but not 'baad', 'baaad', and so on. |
| {n} | Exactly n copies of the preceding character or expression. For example, 'ba{2}d' matches 'baad', but not 'bd', 'bad', 'baaad' and so on. One special usage is to exclude certain expression using {0}. |
| {n1-n2} | At least n1 copies, but no more than n2 copies of the preceding character or expression. For example, 'ba{1-2}d' matches 'bad' and 'baad', but not 'bd', 'baaad', 'baaaad', and so on. |
| {n+} | At least n copies of the preceding character or expression. For example, 'ba{2+}d' matches 'baad', 'baaad', 'baaaad', and so on, but not 'bd' and 'bad'. |
| (exp1|exp2|exp3) | Any one of the expressions separated by the alternation symbol ( | ). For example, '(pine|crab)apple' matches 'pineapple' and 'crabapple'. |
|
(exp)* |
The special symbol should be applied to the expression instead of just the preceding character. For example, '(abc)*def' matches 'def', 'abcdef', 'abcabcdef', 'abcabcabcdef', and so on; '(abc){1-2}def' matches 'abcdef' and 'abcabcdef', but not 'def', 'abcabcabcdef', 'abcabcabcabcdef', and so on. |
| Type Of Text To Be Found | Example Of Regular Expression |
| Quoted string | "[^"]+" |
| Hexadecimal integer | [0-9a-fA-F]+ |
| Floating-point number | [\+\-]? ( [0-9]+\.[0-9]* | [0-9]*\.[0-9]+ | [0-9]+ ) ([eE][\+\-]?[0-9]+)? |
| Date of any format | ( ([0-9]{1-2}/){2}[0-9]{2} | ([0-9]{1-2}/){2}[0-9]{4} | ([0-9]{1-2}\.){2}[0-9]{2} | ([0-9]{1-2}\.){2}[0-9]{4} | [0-9]{4}(\-[0-9]{1-2}){2} | [0-9]{1-2}\-[a-zA-Z]{3}\-[0-9]{2} | [a-zA-Z]{3}(\.)?_[0-9]{1-2},?_[0-9]{4} | [a-zA-Z]{3+}_[0-9]{1-2},?_[0-9]{4} ) |
| Time of any format | [0-9]{1-2} (:[0-9]{2}){1-2} _? (am|AM|pm|PM)? |
| Domestic phone number (US & Canada) | ( (1\-)?[1-9][0-9]{2}\- | (1\()?[1-9][0-9]{2}\) | (1\.)?[1-9][0-9]{2}\. | (1_)?[1-9][0-9]{2}_ ) [1-9] ( [0-9]{2}[\-_][0-9]{4} | [0-9]{6} ) |
| Social security number | ( [1-9][0-9]{2}\-[0-9]{2}\-[0-9]{4} | [1-9][0-9]{2}_[0-9]{2}_[0-9]{4} | [1-9][0-9]{8} ) |
| IP address | [1-9][0-9]{0-2} (\.(0|[1-9][0-9]{0-2})){3} |
| Email address | (mailto:)? [0-9a-zA-Z\_][0-9a-zA-Z\_\-]* (\.[0-9a-zA-Z\_][0-9a-zA-Z\_\-]*)* @ ( [1-9][0-9]{0-2} (\.(0|[1-9][0-9]{0-2})){3} | (www\.|WWW\.|ftp\.|FTP\.){0} ([0-9a-zA-Z\_][0-9a-zA-Z\_\-]*\.)+ [a-zA-Z]{2-3} ) |
| HTTP address | ( https?:// (ftp\.|FTP\.){0} ([0-9a-zA-Z\_][0-9a-zA-Z\_\-]*\.)+ [a-zA-Z]{2-3} | (www|WWW)\. ([0-9a-zA-Z\_][0-9a-zA-Z\_\-]*\.)+ [a-zA-Z]{2-3} | (https?://)? [1-9][0-9]{0-2} (\.(0|[1-9][0-9]{0-2})){3} ) (:[0-9]+)? ([/\?#][^\[\]\)\}>'"_$]*)? |
| FTP address | ( ftp:// ([^/\?#\[\]@_$]+@)? ( [1-9][0-9]{0-2} (\.(0|[1-9][0-9]{0-2})){3} | (www\.|WWW\.){0} ([0-9a-zA-Z\_][0-9a-zA-Z\_\-]*\.)+ [a-zA-Z]{2-3} ) | ([^/\?#\[\]@_$]+@)? (ftp|FTP)\. ([0-9a-zA-Z\_][0-9a-zA-Z\_\-]*\.)+ [a-zA-Z]{2-3} ) (:[0-9]+)? ([/\?#][^\[\]\)\}>'"_$]*)? |
| Go to top |
This page was last modified on 10/24/2005.