Using Ascii code for left quote in regex

To get started, here is the current tool that I use to test my regular expression: http://www.myregextester.com/index.php

Here is my test line: Test ","," Data

There is a left quote, a right quote and a direct quote.

I am trying to create a regex that ensures that the given string does not contain a left quote. I tried to use ascii code for the left quote, but it does not work: ^[^\x93]+$

I could use ascii codes for specific letters, and the regex works as expected; however, I cannot use ascii code for left quotes. Why not?

+4
source share
1 answer

ascii :

[\x{201C}]

: http://regex101.com/r/pY9uF1

, .net :

[\u201C]

: http://regex101.com/r/gB6lN1

, .net, , , , - :

string pattern = @"[\u201C]";
string input = 'Test ","," Data';
Match m = Regex.Match(input, pattern, RegexOptions.IgnoreCase);
if (m.Success)
   Console.WriteLine("The string contains a left quote!");
+3

All Articles