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



  • 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!



  • 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


Log in to reply