See a list of regular expression symbols for use with C#

The following table shows useful symbols, commands, and other items that you can use in regular expressions used by a C# program.
Item Purpose
\ Either begins a special symbol such as \n or escapes the following character
^ Matches the beginning of string (or line if in multiline mode)
$ Matches the end of string (or line if in multiline mode)
\A Matches the beginning of string (even if in multiline mode)
\Z Matches the end of string (even if in multiline mode)
* Matches the preceding character zero or more times
+ Matches the preceding character one or more times
? Matches the preceding character zero or one time
. Matches any character
[abc] Matches any one of the characters inside the brackets
[^abc] Matches one character that is not inside the brackets
[a-z] Matches one character in the range of characters
[^a-z] Matches one character that is not in the range of characters
x|y Matches x or y
(pattern) Makes a match group
(?pattern) Makes a match group and gives it a name
\n Refers to a previously defined group
(?:pattern) Make a non-capturing group (a group that you can't later refer to)
{n} Matches exactly n occurrences
{n,} Matches n or more occurrences
{n,m} Matches between n and m occurrences
(?=...) Positive lookahead (must match the pattern at this point)
(?!...) Negative lookahead (must not match the pattern at this point)
(?<=...) Positive lookbehind (the preceding text must match the pattern)
(? Negative lookbehind (the preceding text must not match the pattern)
\b Matches a word boundary
\B Matches a non-word boundary
\d Matches a digit
\D Matches a non-digit
\f Matches a form-feed
\n Matches a newline
\r Matches a carriage return
\s Matches white space (space, tab, form-feed, etc.)
\S Matches non-white space
\t Matches a tab
\v Matches a vertical tab
\w Matches a word character (includes underscore)
\W Matches a non-word character

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.