Reputation: 2490
I cannot seem to figure this out this out for the life of me.
I am simply trying to match this string with double quotes "emailaddress":"[email protected]"
I've tried several attempts at the regex and this is the closest.
Regex test = new Regex("@\"emailAddress\":\"[email protected]\"");
What is wrong with my syntax?
Upvotes: 0
Views: 111
Reputation: 28499
Use Regex.Escape() to do the escaping for use in the regular expression for you. Then you only have to escape the double quotes the usual way:
var term = @"""emailaddress"":""[email protected]""";
Regex test = new Regex(Regex.Escape(term), RegexOptions.IgnoreCase);
Use the RegexOptions.IgnoreCase flag in the Constructor to specify that case should be ignored.
Upvotes: 1
Reputation: 14383
Regex is case sensitive by default. You need to change the "A" in "emailAddress" to a lower case "a":
\"emailaddress\":\"[email protected]\"
Upvotes: 0