Hello, @hoang-ngoc, @peterjones and All,
The following single search regex could be used and, with an empty replace field, would delete any line with a valid user-name :
SEARCH (?i-s)(?=^[a-z0-9])(?=.*[a-z0-9]:)(?=.*[a-z].*:)^[a-z0-9_.-]{6,15}:.*\R?
REPLACE Leave EMPTY
Notes :
The (?i-s) forces an insensitive search process and the regex dot . standing for a single standard character
Then the main part is ^[a-z0-9_.-]{6,15}:.*\R? which searches for 6 to 15 chars, before a colon which can be, either, a standard letter or digit, an underscore, a period or a dash, followed by the remainder of current line and a possible line_break
This part will be valid ONLY IF, in addition, these three lookaheads are TRUE, at beginning of current line :
A letter or digit begins the user-name ( part (?=^[a-z0-9]) )
A letter or digit ends the user-name ( part (?=.*[a-z0-9]:) )
The user-name contains, at least, ONE letter ( part (?=.*[a-z].*:) )
So, given this INPUT text :
short:•••••••• # < 6 chars ThisIs2good:•••••••• # OK Looong_user-name:•••••••• # > 15 chars us@er'NA=ME:•••••••• # NON-VALID chars ok-chr:•••••••• # OK ( 7 chars and ALL chars ALLOWED ) ABCD-FGHI_12.34:•••••••• # OK ( 15 chars and ALL chars ALLOWED ) 1234-6789:•••••••• # NO letter .User-Name:•••••••• # NON-VALID char at START USER.NAME_:•••••••• # NON-VALID char at END 1ok_again2:•••••••• # OKAfter the replacment, it would remain :the following OUTPUT text :
short:•••••••• # < 6 chars Looong_user-name:•••••••• # > 15 chars us@er'NA=ME:•••••••• # NON-VALID chars 1234-6789:•••••••• # NO letter .User-Name:•••••••• # NON-VALID char at START USER.NAME_:•••••••• # NON-VALID char at ENDBest regards
guy038