This is a pretty simple question but I’m somewhat stumped.
I am capturing sections of text that match “xxxxxxxxxx”. It works fine.
string pattern = "(?<quotePair>\"[^/\"]*\")";
Now I want to make a new pattern to capture “xxxxxxxxxx”… I used:
string pattern2 = "(?<lrquotePair>“[^/\"“]*”)";
For some reason the second pattern won’t catch anything. What am I missing?
Your patterns are more complicated than how you describe them – for example, the first one won’t match
"foo/bar", and the second one won’t match“foo/bar”or“foo"bar”. Perhaps your input falls into one of those categories?If there is an encoding problem, it’s not with the regex – .NET regexes support Unicode just fine. But it might be that you didn’t read the text in the correct encoding in the first place – try printing it out and check that the fancy
“”quotes are still there. In particular, if you useStreamReaderclass with a single-argument constructor (orFile.OpenTexthelper), it defaults to UTF-8 encoding for input, which might not be what you actually have there.