Navigation

    Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

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

    Help wanted · · · – – – · · ·
    2
    2
    489
    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 Pupsi
      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
      • guy038
        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
        Copyright © 2014 NodeBB Forums | Contributors