User to user discussion and support for UltraEdit, UEStudio, UltraCompare, and other IDM applications.

Find, replace, find in files, replace in files, regular expressions
3 posts Page 1 of 1
Is there a way to rewrite the following regex so the replacement becomes defined. My understanding is embedded parentheses cause the replacements \1, \2, etc. to become undefined.

(SVC\*HC(:\w{2,})+):\w(\*)

Sample entries this should match. The part in red should be deleted in the replacement. I'm trying to guarantee this only occurs on a line with SVC*.

SVC*HC:S5102:A*49.39*49.39**1~
SVC*HC:S5102:X*49.39*49.39**1~
SVC*HC:S5102:AB:B*49.39*49.39**1~
SVC*HC:S5102:A*49.39*49.39**1~
SVC*HC:S5102:AB:C*49.39*49.39**1~
Use as search string: (SVC\*HC(?::\w{2,})+):\w(\*)

?: immediately after opening parenthesis changes the group from a marking group to a non marking group. Non marking groups can be nested in other non marking groups or in marking groups. Non marking groups should be always used when back-referencing the string found by the expression inside a group is not needed.
Best regards from Austria
Thanks Mofi that worked. My replacement was \1\2 and it worked.

I could've made the asterisk at the end a look ahead and thus just would've needed \1 as the replacement. Thanks for the tip on the embedded parentheses trick.

(SVC\*HC(?::\w{2,})+):\w(?=\*)
3 posts Page 1 of 1