• Login
Community
  • Login

remove letters only in text

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
3 Posts 2 Posters 7.8k 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.
  • H
    Handa Flocka
    last edited by May 28, 2021, 6:24 PM

    Hi everyone,
    I am trying to remove “only letters” from a text that has characters, spaces, and numbers"
    for example:

    just some text 1:2:3
    some 1|2|3 text
    text        123
    123 some other text
    

    to became:

     1:2:3
     1|2|3 
            123
    123
    

    I tried some online code but it does remove everything excepts numbers including characters " : " and " | " and (spaces)
    thank you

    P 1 Reply Last reply May 28, 2021, 6:34 PM Reply Quote 0
    • P
      PeterJones @Handa Flocka
      last edited by May 28, 2021, 6:34 PM

      @Handa-Flocka ,

      I tried some online code but it does remove everything excepts numbers including characters " : " and " | " and (spaces)

      When asking for search-and-replace advice, show us what you’ve already tried (don’t just say “I tried some online code”).

      The official docs tell you about each of the character classes (https://npp-user-manual.org/docs/searching/#character-classes ). Since you are wanting to delete letters only (not numbers or punctuation) there are two reasonable classes you could use; the first would be [\u\l] which matches any uppercase or lowercase character; the second would be to used the named class [[:alpha:]].

      So you would do your search/replace as:

      • Search Mode = regular expression
      • FIND = [[:alpha:]] or [\u\l]
      • REPLACE = (leave it empty)

      ----

      Do you want regex search/replace help? Then please be patient and polite, show some effort, and be willing to learn; answer questions and requests for clarification that are made of you. All example text should be marked as literal text using the </> toolbar button or manual Markdown syntax. To make regex in red (and so they keep their special characters like *), use backticks, like `^.*?blah.*?\z`. Screenshots can be pasted from the clipboard to your post using Ctrl+V to show graphical items, but any text should be included as literal text in your post so we can easily copy/paste your data. Show the data you have and the text you want to get from that data; include examples of things that should match and be transformed, and things that don’t match and should be left alone; show edge cases and make sure you examples are as varied as your real data. Show the regex you already tried, and why you thought it should work; tell us what’s wrong with what you do get. Read the official NPP Searching / Regex docs and the forum’s Regular Expression FAQ. If you follow these guidelines, you’re much more likely to get helpful replies that solve your problem in the shortest number of tries.

      1 Reply Last reply Reply Quote 2
      • H
        Handa Flocka
        last edited by May 28, 2021, 6:41 PM

        @PeterJones said in remove letters only in text:

        [[:alpha:]]

        @PeterJones It worked
        Thank you! and for the explanation I will try to learn from it

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