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

Find, replace, find in files, replace in files, regular expressions
6 posts Page 1 of 1
Scan and select entire lines that have more than 4 occurrences of the colon ":" character in them.
Perl regex:

^(?:[^:\r\n]*:){5}.*\r\n
Fantastic! :mrgreen:
I'm back nearly a decade later to ask for a string that does the opposite. So instead of selecting lines with, say, 5 more than ":" in them, how about lines with 5 or LESS ":" in them? I suspect it's a trivial modification.

Example text block:

Code: Select all
AAA:BBB:CCC:DDD:EEE:FFF:GGG
AAA:BBB:CCC:DDD:EEE:FFF
AAA:BBB:CCC:DDD:EEE
AAA:BBB:CCC:DDD
AAA:BBB:

The first line should not be found/selected, but each other line should be found and selected by the regular expression find.
Use as Perl regular expression search string: ^(?:[^:\r\n]+|(?:[^:\r\n]*?:){1,5}[^:\r\n]*)(?:\r?\n|\r|$)

This regular expression selects an entire line including line termination containing at least 1 character (empty lines are ignored) and not containing any colon or just 1 to 5 colons.
Best regards from Austria
Works perfect, thanks.
6 posts Page 1 of 1