How to mark lines with under "x" characters after : in a line.
-
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 for6to15chars, 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
-
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login