Reputation: 8574
I'm a little stumped here. I had this method, which was working fine until just recently:
internal static bool IsZplFormat(string szString)
{
var regex = new Regex(@"\^XA.*\^XZ\\r\\n");
return regex.IsMatch(szString);
}
That would work fine given the following string (taken from my unit test):
const string zplSample = "^XA blah blah blah ^XZ\r\n";
What appears to be happening now, is that I'm getting something like this:
const string zplSample = "^XA blah blah \"blah ^XZ\r\n";
And now my regex doesn't match anymore.
I thought the .*
should match all characters, but it seems to be getting tripped up on that double quote. Any ideas on how I can get this working again?
Upvotes: 1
Views: 663
Reputation: 100331
Testing here...
string zplSample = "^XA blah blah blah ^XZ\r\n";
string zplSample1 = "^XA blah blah \"blah ^XZ\r\n";
Console.WriteLine(new Regex(@"\^XA.*\^XZ\r\n").IsMatch(zplSample));
Console.WriteLine(new Regex(@"\^XA.*\^XZ\r\n").IsMatch(zplSample1));
Console.ReadKey();
Output
True
True
What did I change? The regex pattern to @"\^XA.*\^XZ\r\n"
. (From two backslashes
to one) (\\r\\n
)
Upvotes: 1