using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"[!-\/:-@[-`{-~]";
string input = @" ! U+0021 EXCLAMATION MARK
"" U+0022 QUOTATION MARK
# U+0023 NUMBER SIGN
$ U+0024 DOLLAR SIGN
% U+0025 PERCENT SIGN
& U+0026 AMPERSAND
' U+0027 APOSTROPHE
( U+0028 LEFT PARENTHESIS
) U+0029 RIGHT PARENTHESIS
* U+002A ASTERISK
+ U+002B PLUS SIGN
, U+002C COMMA
- U+002D HYPHEN-MINUS
. U+002E FULL STOP
/ U+002F SOLIDUS
: U+003A COLON
; U+003B SEMICOLON
< U+003C LESS-THAN SIGN
= U+003D EQUALS SIGN
> U+003E GREATER-THAN SIGN
? U+003F QUESTION MARK
@ U+0040 COMMERCIAL AT
[ U+005B LEFT SQUARE BRACKET
\ U+005C REVERSE SOLIDUS
] U+005D RIGHT SQUARE BRACKET
^ U+005E CIRCUMFLEX ACCENT
_ U+005F LOW LINE
` U+0060 GRAVE ACCENT
{ U+007B LEFT CURLY BRACKET
| U+007C VERTICAL LINE
} U+007D RIGHT CURLY BRACKET
~ U+007E TILDE";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx