regex - Java Pattern.compile ignoring escaped double quotes (\") -
i having hard time figuring out pattern ignore escaped quotes. want this:
"10\" 2 topping pizza, pasta, or sandwich $5 each. valid until 2pm. carryout only.","blah blah" to match as:
1> "10\" 2 topping pizza, pasta, or sandwich $5 each. valid until 2pm. carryout only." 2> "blah blah" i have been trying this:
pattern pattern = pattern.compile("\"[^\"]*\""); matcher matcher = pattern.matcher(filteredcoupons); and
1> "10\" 2> ","
the regex looking is
"[^"\\]*(?:\\.[^"\\]*)*" see demo
in java,
string pattern = "\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"";
Comments
Post a Comment