Community
    • Login

    Regex: Delete all lines containing characters other than [a-z], [A-Z], and [-]

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 708 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.
    • Iskandar The PupsiI
      Iskandar The Pupsi
      last edited by

      Hello.

      Thanks again in advance:

      I have a list and I want to delete every line, which contains a character which is not
      [a-z], [A-Z], and [-].

      so:
      bl-a
      bla
      blà
      bl%
      blo
      bló
      blO

      should become

      bl-a
      bla
      blo

      Thank you very much!

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

        Hello, @iskandar-the-pupsi and All,

        Use the following regex S/R :

        SEARCH ^.*[^A-Za-z\r\n-].*\R

        REPLACE Leave EMPTY

        Notes :

        • The ^ symbol ,beginning the character class, is the negation character

        • The - symbol must be located at the end of the character class as it’s a special** char inside class character

        • The \R syntax matches any kind of line-break

        Best Regards

        guy038

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