Does idea support replace groups when replacing with regexes?

How do you specify a replace (capture) group in idea
whern replacing with regexes?

4 comments
Comment actions Permalink

There don't seem to be any replies to this question -- was it ever answered? Is it possible to reference a matched group in a replace using regular expressions?

for example:

Find: before(a-ZA-Z]+)

Replace: \1after

would change text: beforeToday
to Todayafter

Is there a way to do this kind of thing or do I need an external tool like Perl?

0
Comment actions Permalink

Charlie Evett wrote:

There don't seem to be any replies to this question -- was it ever answered? Is it possible to reference a matched group in a replace using regular expressions?

for example:

Find: before(a-ZA-Z]+)

Replace: \1after

would change text: beforeToday
to Todayafter

Is there a way to do this kind of thing or do I need an external tool like Perl?


I requested this functionality in SCR #8075. You might want to vote for
it. See--
http://www.intellij.net/tracker/idea/viewSCR?publicId=8075

I sure hope they get to this and the variety of other requests filed
against find.

Jon

0
Comment actions Permalink

OK, I found my answer with more diligent searching. You have to use $1 as the match token in the replace rather than \1.

So
Find: before(+

Replace $1after

works.

3
Comment actions Permalink

Charlie Evett wrote:

OK, I found my answer with more diligent searching. You have to use $1 as the match token in the replace rather than \1.

So
Find: before(+

Replace $1after

works.


Cool. I wonder when that changed. Could somebody at IntelliJ update the
SCR #8075 (if appropriate)?

Jon

0

Please sign in to leave a comment.