This is the 7th day of my participation in the November Gwen Challenge. Check out the details: The last Gwen Challenge 2021
qualifiers
“?” “*” means that the preceding character must appear zero or more times. “+” means that the preceding character must appear one or more times. “{a}” sets the number of matches to a. The contents of a parenthesis are equivalent to one character
Or operation
A (apple | peach) through “|” can match multiple character or string, as long as one is matched to the can through pay attention to when using the Boolean or should fully use parentheses to determine the scope of the solution
Character classes
To match ABC, you can write “[ABC]+” if there are too many types of characters to match such as 1 to 26 characters, you can use **”-“** concatenation characters, Written as “[a-z]+” if you prefix the square brackets with an ^ sharpener (broken character), you want to match characters other than those listed after the sharpener
metacharacters
“\D” numeric characters” \W” Word characters (English, digits and underscores) “\S” whitespace (including Tab and newline characters)” \D” non-numeric characters “\W” non-word characters” \S” non-whitespace characters “. “Any character that is not a newline character
The boundary of the “\b” word matches the position on both sides of each word.” ^ “matches the beginning of the line and” $” matches the end of the line
Greed and laziness match
“<. +? >” is used to match tags such as
< HTML >, where “<.+>” will wrap the contents of
, including the text between >
Finally, there is an online regex test site called Regex101. This site can implement a lot of regex content and can switch between different languages, which is quite useful