In C #, a regular expression is a tool used to query certain characters or numbers in a string of characters given. Similar to the search function in office software, you can find it with precision or with a fuzzy look.
Metacharacters
Metacharacters |
Description |
. |
Match any character other than line break |
\b |
Match the beginning or end of a word |
\d |
Match numbers |
\s |
Match any of the whitespace characters |
\w |
Match letters or numbers or underscores or kanji |
^ |
Match the start of a string |
$ |
Match the end of a string |
Qualifier:
Qualifier |
Description |
* |
Repeat 0 or more times |
+ |
Repeat one or more times |
? |
Repeat 0 or one time |
N |
Repeat n times |
{N,} |
Repeat N or more times |
{N,m} |
Repeat N to M times |
Assertion:
Assertion syntax |
Description |
(? =pattern) |
Forward positive assertion that matches the position in front of the pattern |
(?! Pattern |
Forward negative assertion that matches a position not followed by pattern |
(? <=pattern) |
Back-to-positive assertion that matches the position behind the pattern |
(? <!pattern) |
Back to negative assertion, matching the position of the previous not pattern |
C # Second article--about regular expressions in C #