【the waiter】announcement:

Online regular matching
4925  |   |   |  52

🌟 documentation

📌 basic character

symboldescriptionexamplematching content
.match any single character (except newline characters)a.baab, acb
\ dmatch any numeric character[0-9]\ d\ d12, 34
\ Dmatch any non-numeric character[^ 0-9]\ D\ Dab, xy
\ wmatch letters, numbers or underscores[a-zA-Z0-9 _]\ w\ w\ wabc, 123
\ Wmatch any non-alphanumeric or underscore characters\ W\ W!, @ @
\ smatch white space characters (spaces, tabs, line feeds, etc.)\ sspaces, tabs
\ Smatch any non-blank character\ S\ S\ Sabc, 123

📏 quantity qualifier

symboldescriptionexamplematching content
*match the preceding character for zero or more times {0,}a* empty string, a, aa
+match the preceding characters one or more timesa+ a, aa, aaa
?match the preceding characters zero times or once, {0recover1}a? empty string, a
{n}match the preceding character exactly n timesa {3} aaa
{n,}match the preceding characters at least n timesa {2,} aa, aaa
{nrecast m}match the preceding characters at least n times, up to m timesa {2pm 4} aa, aaa, aaa

🚩 boundary match

symboldescriptionexamplematching content
^ the beginning of the matching string^ HelloHello in Hello!`
$ match the end of the stringWorldmatch $World! in Hello World!
\ bmatch word boundary\ bword\ bword in word
\ Bmatch non-word boundaries\ Bword\ Bword in passwords

🎯 grouping and referencing

symboldescriptionexamplematching content
()capture group and save the matching substrings as a group(abc) +abc, abcabc
(?:...)non-capture group, only grouping but not saving substrings(?: abc) +abc, abcabc
\ nreference capture group. n is the group number (a) (b)\ 1\ 2abab

🔍 character set and character class

symboldescriptionexamplematching content
[abc]matches any character in a, b or c[abc]a, b, c
[^ abc]match any character except a, b or c[^ abc]d, e
[aMusz]match any lowercase letter from a to z[aripz]a, b, c
[Amurz]match any uppercase letter from A to Z[Amurz]A, B, C
[0-9]match any numeric character[0-9]1, 2, 3

example of 📚 common mode

descriptionregular expressionsample datamatching result
📞 matches phone number\ (\ d {3}\)\ d {3} -\ d {4}(123) 456-7890match
📧 verifies email address^ [A-Za-z0-9.9% address -] + @ [A-Za-z0-9.9 -] +\. [A-Za-z] {2,} $example@ example.commatch
📅 match date format^\ d {4} -\ d {2} -\ d {2} $2024-08-17match
🌐 matches IP address`^ ((25 0-52 0-4 0-901? 0-9 0-9?).) {3} (25 0-5
🔗 match URL^ https?:\ /\ / [^\ sUniverse. Match #] .[ ^\ s] * $https://www.example.commatch
🏷️ matches HTML tags< (\ /? [^ >] +) >< div >, < / div >match
📮 matches Postal Code^\ d {5} (-\ d {4})? $12345, 12345-6789match
CSS color code extracted by 🎨`# (a-fA-F0-9 {6}a-fA-F0-9 {3})`# ffffff, # fff

⚠️ escape character

symboldescriptionexamplematching content
\escape character, which is used to match characters with special meaning\ .match period .