C Sharp RegExp

From Pigbert Wiki

a clean list of the symbols (http://www.exforsys.com/tutorials/csharp/regular-expressions-and-csharp-.net.html)

Specisl Operators

  • Special Characters: . $ ^ { [ ( | ) * + ? \
  • @: lets the compile to interpret the string literally, i.e. eliminating the need for the escape character.

Regular Expression Options

Regular Expression Options can be used in the constructor for the Regex class.

  • RegexOptions.None
Specifies that no options are set.
  • RegexOptions.IgnoreCase:
Specifies case-insensitive matching.
  • RegexOptions.Multiline:
Multiline mode. Changes the meaning of ^ and $ so they match at the beginning and end, respectively, of any line, and not just the beginning and end of the entire string.
  • RegexOptions.Singleline:
Specifies single-line mode. Changes the meaning of the dot (.) so it matches every character (instead of every character except \n).
  • RegexOptions.ExplicitCapture:
Specifies that the only valid captures are groups that are explicitly named or in the form (?<name>...).
  • RegexOptions.IgnorePatternWhitespace:
Eliminates unescaped white space from the pattern and enables comments marked with the hash sign (#).
  • RegexOptions.Compiled:
Specifies that the regular expression is compiled to an assembly. The regular expression will be faster to match but it takes more time to compile initially. This option (although tempting) should only be used when the expression will be used many times. e.g. in a foreach loop
  • RegexOptions.ECMAScript:
Enables ECMAScript-compliant behavior for the expression. This flag can be used only in conjunction with the IgnoreCase, Multiline, and Compiled flags. The use of this flag with any other flags results in an exception.
  • RegexOptions.RightToLeft:
Specifies that the search will be from right to left instead of from left to right.
Personal tools