Community
    • Login

    How to remove lines that do not contain ONLY alphanumeric characters.

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 1.4k 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.
    • Nicholas WetzelN
      Nicholas Wetzel
      last edited by

      I want to remove all the lines from my txt if the line does not have ONLY alphanumeric characters.

      This means if there is one or more non alpha-numeric characters in a line, I want to remove the line.

      1 Reply Last reply Reply Quote 0
      • Terry RT
        Terry R
        last edited by

        @Nicholas-Wetzel said:

        one or more non alpha-numeric

        You could use the Mark feature, which I suggest as you may otherwise find that you have removed lines you did not wish to do so.

        So with Mark (under Search, then mark) have the Find What line containing
        [^0-9a-z]
        Make sure the ‘Bookmark line’ is ticked and have the Search Mode set to 'regular expression. Click on mark All.
        All lines containing at least one character which is NOT a number (0-9) or a alpha (a-z & A-Z) will be marked by a symbol at the start of a line (mine is a blue circle).

        At this point you could just select the option in the menu (under Search) called Bookmark, then Remove Bookmarked Lines, however i strongly suggest you check at least some of the bookmarked lines as I suspect you will find you may have forgotten other characters which you wish not to select. If so then they can also be added to the regex inside the [], before selecting Mark again, Clear Marks and trying again.

        Terry

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