Community
    • Login

    Filter a certain amount of letters out of a code

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 3 Posters 1.8k Views 1 Watching
    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.
    • Daniel ElpunktD Offline
      Daniel Elpunkt
      last edited by

      So basically I am having a long list of codes with 12 characters, including A-Z and 0-9.
      I want to delete every code which has more than 3 letters.
      for exampe: C9RUEOCXK60E
      has more than 3 letters - should be filtered out.
      C95678C3210E has 3 letters - I want to keep this one.

      How am i gonna do this?

      1 Reply Last reply Reply Quote 0
      • gerdb42G Offline
        gerdb42
        last edited by

        This could be done with a RegEx: \b([[:alpha:]]+?[[:digit:]]*){4,}\b to search for and an empty String for replacement. If you want to delete the entire line, replace the second \b with \R.

        What it does: after a word boundary (\b) look for the shortest possible sequence of alpha-characters ([[:alpha:]]+?), optionally followed by a sequence of digits ([[:digit:]]*) with at least four repetitions ({4,}) up to the next word boundary.

        1 Reply Last reply Reply Quote 0
        • guy038G Offline
          guy038
          last edited by guy038

          Hi, @daniel-elpunkt,

          @gerdb42’s regex works fine. Just an other formulation, based on the fact that your codes do not contain lower-case letters :

          SEARCH \b(\d*\u){4,}\d*\b

          REPLACE EMPTY

          And, as @gerdb42 said, if you have a single code, only, of 12 characters long, per line, just replace the final \b by the syntax \R, which represents any End of Line characters, whatever the file type ( Windows, Unix or Mac )

          SEARCH \b(\d*\u){4,}\d*\R

          REPLACE EMPTY

          After replacement, only codes, containing 0, 1, 2 or 3 capital letters, are kept !

          Best Regards,

          guy038

          1 Reply Last reply Reply Quote 0

          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
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors