Test php regular expression here:
http://www.phpliveregex.com/
Important syntax:
\a control characters bell
\b backspace
\f form feed
\n line feed
\r carriage return
\t horizontal tab
\v vertical tabspecial character: \. \{ \} \s |
Any whitespace character |
\S |
Any non-whitespace character |
\d |
Any digit |
\D |
Any non-digit |
\w |
Any word character (letter, number, underscore) |
\W |
Any non-word charact |
^ |
Start of line | |||||||
$ |
End of line | |||||||
\A |
Start of string | |||||||
\z |
End of string |
Examples:
.atmatches any three-character string ending with "at", including "hat", "cat", and "bat".[hc]atmatches "hat" and "cat".[^b]atmatches all strings matched by.atexcept "bat".[^hc]atmatches all strings matched by.atother than "hat" and "cat".^[hc]atmatches "hat" and "cat", but only at the beginning of the string or line.[hc]at$matches "hat" and "cat", but only at the end of the string or line.\[.\]matches any single character surrounded by "[" and "]" since the brackets are escaped, for example: "[a]" and "[b]".