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

Find, replace, find in files, replace in files, regular expressions
5 posts Page 1 of 1
Notice the following line:

AAA:BBB:CCC:DDD:EEE:FFF:GGG:HHH:III

I looking for an expression that can search backwards selecting the 4th ":" from the right and everything after it, like:

AAA:BBB:CCC:DDD:EEE:FFF:GGG:HHH:III
With Perl regular expression the search string for this task is: (?::[^:\r\n]+){4}$

(?:...) is a non marking group.

:[^:\r\n]+ ... find a colon with 1 or more characters being NOT a colon or a carriage return or a line feed.

{4}$ ... the expression in the non marking group must be applied exactly 4 times at end of a line not matching the newline characters.
Best regards from Austria
Stupendous. Thanks.
Hmm, How about when one or more of the ":" are consecutive at the end of the line? Say "::" or "::::". For example:

(?::[^:\r\n]+){4}$ catches this:
AAA:BBB:CCC:DDD:EEE:FFF:GGG:HHH:III

But does not catch this:
AAA:BBB:CCC:DDD:EEE:FFF:GGG:HHH:

or this:
AAA:BBB:CCC:DDD:EEE:FFF:GGG::HHH:III

or this:
AAA:BBB:CCC:DDD:EEE::::
Replace in search string + (1 or more times) by * (0 or more times), i.e. search string is: (?::[^:\r\n]*){4}$
Best regards from Austria
5 posts Page 1 of 1