|
Literal Characters ...
- \0 zero NULL
- \t lowercase t TAB
- \n lowercase n New Line
- \v lowercase v Vertical tab
- \f lowercase f Form Feed
- \r lowercase r Carriage Return
- \xnn lowercase x Hexadecimal character represented by nn
- \d lowercase d matches any digit 0-9
- \D uppercase D matches what is not a digit
- \w lowercase w matches any alphanumeric, a-zA-Z0-9_
- \W uppercase W matches what is not alphanumeric
- \c lowercase c matches any alphabetic, a-zA-Z
- \C uppercase C matches what is not alphabetic, a-zA-Z
- \s lowercase s matches any whitespace character
- \S uppercase S matches any non-whitespace character
Punctuation Characters ...
- ^ carat match the beginning of a string or line
- $ dollar sign match the end of a string or line
- . stop wildcard - matches any character
- * asterisk zero or more matches
- + plus one or more matches
- ? question mark the match is optional, may or may not match
- | vertical bar alternative (or)
- \ back slash escape character, the following character has a specific meaning
- ( ) round brackets subexpression
- { } braces number of occurrences to match
- [ ] square brackets sequence or range of characters to match
|
Examples ...
text='alpha' expression='qwe' will not find a match, and so return a -1.
text='alpha' expression='h' will find a match starting in position 4, and so return a 4.
text='alpha' expression='\w' will find a match starting in position 1, and so return a 1.
text='alpha' expression='\W' will not find a match, and so return a -1.
text='alp25a' expression='\d' will find a match starting in position 4, and so return a 4.
text='myname@emailaddress.zx' expression='\w+@\w+\.\w{2,3}$' will find a match starting in position 1, and so return a 1.
text='myname@emailaddress.zxy' expression='\w+@\w+\.\w{2,3}$' will find a match starting in position 1 and so return a 1.
text='myname@emailaddress.zxywv' expression='\w+@\w+\.\w{2,3}$' will not find a match, and so return a -1.
text='myname@emailaddress.zx' expression='\w+@\w+\.\w{2,3}' will find a match starting in position 1, and so return a 1.
text='myname@emailaddress.zxy' expression='\w+@\w+\.\w{2,3}' will find a match starting in position 1, and so return a 1.
text='myname@emailaddress.zxywv' expression='\w+@\w+\.\w{2,3}' will find a match starting in position 1, and so return a 1.
text='alph123' expression='^\w+\d' will find a match starting in position 1, and so return a 1.
text='alph123' expression='^\w\d' will not find a match, and so return a -1.
|