java - How to escape a invalid string using regular expression? -
i have below string, being escaped incorrectly.
"\"name\":\"\"/test/name=testame\" 001\"" i use regular expression find strings contain above pattern , replace correct escape pattern. @ moment, i'm using hard coding find , replace string, not want.
ps: i've no control of above string pattern. i'll have handle incorrectness in application.
any suggestions?
this help:
\\finds\\"finds "[a-za-z_-]+enough match labels , names[0-9]+match number without screwing or finding much:,=literals , don't need escaping
put 'em , you've got night regular expression.
i don't see in question prohibit doing substitution using parenthesis, didn't tool you're using replacing can't give many hints. you'll put
(part 1 of regexp)some literal hate(part 2 of regexp) as matcher ,
\1some literal like\2 as substitution string. if going perl you'd use
s\matcher\substituter\g. you perl one-liner, you'd have double careful in re-escaping quotes.
Comments
Post a Comment