文档介绍:Anchors Sample Patterns
^ Start of line + ([A-Za-z0-9-]+) Letters, numbers and hyphens
\A Start of string + (\d{1,2}\/\d{1,2}\/\d{4}) Date (. 21/3/2006)
$ End of line + ([^\s]+(?=\.(jpg|gif|png))\.\2) jpg, gif or png image
\Z End of string + (^[1-9]{1}$|^[1-4]{1}[0-9]{1}$|^50$) Any number from 1 to 50 inclusive
\b Word boundary + (#?([A-Fa-f0-9]){3}(([A-Fa-f0-9]){3})?) Valid hexadecimal colour code
\B Not word boundary + ((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}) 8 to 15 character string with at least one
\< Start of word upper case letter, one lower case letter,
\> End of word and one digit (useful for passwords).
(\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,6}) Email addresses
(\<(/?[^\>]+)\>) HTML Tags
Character Classes
\c Control character These patterns are intended for reference purposes and have not been extensively tested.
Note
\s White space Please use with caution and test thoroughly before use.
\S Not white space
\d Digit
Quantifiers Ranges
\D Not digit
\w Word * 0 or more + . Any character except
\W Not word *? 0 or more, ungreedy + new line (\n) +
\xhh Hexadecimal character hh + 1 or more + (a|b) a or b +
\Oxxx Octal character xxx +? 1 or more, ungreedy + (...) Group +
? 0 or 1 + (?:...) Passive Group +
?? 0 or 1, ungreedy + [abc] Range (a or b or c) +
POSIX Character Classes
{3} Exactly 3 + [^abc] Not a or b or c +
[:upper:] U