开发者

Eclipse find and replace with regex is not working with "(?=regex)"?

I tried to find and replace some tags with SpringSource Tool Suite(Eclipse). I want to change <annotation-driven /> to <mvc:annotation-driven /> but I don't want <beans:bean ..> to be <mvc:beans:bean ...>.

So I made regex like this(actually the regex is longer than this but I made it simple):

Find: <(?=[^b])

Replace With: <mvc:

I added (?=regex) expression to avoid first character to be selected. It finds successfully but doesn't replace anything. If I remove the (?=regex) expression, it works fine but the first character is removed.

I开发者_StackOverflows it a bug? Or Did I do something wrong?


I would have used (?!b), but (?=[^b]) should work too. Anyway, try this:

Find: <([^b])

Replace: <mvc:$1

$1 should insert the contents of the first capturing group, i.e., the letter that isn't b.

If it doesn't work with $1, try <mvc:\1 instead.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜