Community
    • Login

    How to mark lines with under "x" characters after : in a line.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    21 Posts 8 Posters 9.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • guy038G
      guy038
      last edited by

      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:••••••••                 #  OK
      

      After 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 END
      

      Best regards

      guy038

      1 Reply Last reply Reply Quote 1
      • First post
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors