开发者

Problem with Replace in Eclipse

开发者 https://www.devze.com 2022-12-25 06:56 出处:网络
I\'m using regex to match all non-quoted property names in my json files. Eclipse has no problem finding the desired matches, but when I want to replace the matched strings with \"$2\", I get this err

I'm using regex to match all non-quoted property names in my json files. Eclipse has no problem finding the desired matches, but when I want to replace the matched strings with "$2", I get this error: Match string has changed in file filename.json. Match skipped

Here's 开发者_开发技巧the regex I'm using:

((\w+)\s*(?!['"])(?=:))

Any idea on how to work around this issue?


It's a known bug: replace don't work when using a regex with a lookahead


It sounds like a problem with the tool rather than the regex, but I'm not familiar with Eclipse so I can't be more specific. Could it be expecting \2 instead of $2?

Assuming the property names match \w+, that regex should work fine, although the negative lookahead is redundant. If the next character is a colon--(?=:)--then of course it isn't an apostrophe or quotation mark--(?!['"]).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号