0

I am trying to find a specific regexp. I have the next example:

bla1 bla2 VAR_1 && K_VAR_1 clo1 clo2 .... bla3 bla4 REVAR && K_REVAR clo77 clo88 ....

To find the bold text, I mean, a word and the same word with the "K_" prefix, I use this expression

[\w]+ && K_[\w]+

The result it is OK

VAR_1 && K_VAR_1
REVAR && K_REVAR

but when I have this example

bla1 bla2 VAR_1 && l_NOPE clo1 clo2 ....

of course, I have a bad result, because VAR_1 and NOPE are not the same word but the pattern return it as a result. And my question is, is there an "option" in a regexp to say something like "find this pattern, and the same previous pattern"? When I have to replace, I can use parenthesis to identify the pattern, for example, I can replace "VAR_1 && K_VAR_1" for "VAR1 || VAR1_suf" doing this:

find: ([\w]+) && K_[\w]+
replace: $1 || $1_suf

is there a way to do something like that, but in the find pattern? This expression is wrong, but it may clarify:

find: ([\w]+) && K_($1)

thank you all.

Alexi
  • 9
  • 3

0 Answers0