RegularExpression
posted on 19 Aug 2008 10:07 by saygass in Developer| Basics | |
| . | Match any character except newline. |
| \w | Match any alphanumeric character. |
| \s | Match any whitespace character. |
| \d | Match any digit. |
| \b | Match the begining or end of a word. |
| ^ | Match the beginning of the string. |
| $ | Match the end of the string. |
Repetitions |
|
| * | Repeat any number of times. |
| + | Repeat one or more. |
| ? | Repeat zero or more. |
| {n} | Repeat n times. |
| {n,m} | Repeat at least n but no more thean m times. |
| {n,} | Repeat at least n times. |
Negation |
|
| \W | Match any character that is NOT alphanumeric. |
| \S | Match any character that is NOT alphanumeric. |
| \D | Match any character that is NOT alphanumeric. |
| \B | Match a position that is NOT the beginning or end of a word. |
| [^x] | Match any character that is NOT x |
| [^aeiou] | Match any character that is NOT one of the characters in [ ] |
Credit : http://www.codeproject.com
| Special Types | |
| \p{Lower} | Matches lower case letters from a to z. |
| \p{Upper} | Matches upper case letters from A to Z. |
| \p{ASCII} | Matches all ASCII charaters. |
| \p{Alpha} | Matches all upper and lower case characters. |
| \p{Digit} | Matches all digits from 0 to 9. |
| \p{Alnum} | Matches all numbers and letters. |
| \p{Punct} | Matches all punctuation symbols. |
| \p{Graph} | Matches all visible characters. |
| \p{Print} | Matches all printable characters. |
| \p{Blank} | Matches a tab or space. |
| \p{Cntrl} | Matches a control character. |
| \p{XDigit} | Matches a hexadecimal digit. |
| \p{Space} | Matches a white space character. |
| [a-z&&[^m-p]] | All leters from a-z except m-p |
Credit : http://www.zizasoft.com
| Exam Validater Expression | |
| Address | [^\<\>\'\!\"\@\#\+\%\$\^\*\=\|\\]* |
| Money | (^\$?[0-9]+(,[0-9]{3})*(\.[0-9]{1,2})?$)|(\d{0,10}) |
| ^((?:(?:(?:[a-zA-Z0-9][\.\-\+_]?)*)[a-zA-Z0-9])+)\@((?:(?:(?:[a-zA-Z0-9][\.\-_]?){0,62})[a-zA-Z0-9])+)\.([a-zA-Z0-9]{2,6})$ | |