-1

Is there a RegEx to remove everything but digits and spaces in Notepad++?

I know there is one that removes only digits but i dont need that.

PS: I do not want the lines to be removed

Example:

11234123 alex-james
1412412 mmafsmasdas

After regex:

11234123
1412412
Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92

2 Answers2

1

As the pattern use [^\d ]+. Almost what Poul Bak proposed, but change * into +, i.e. the sequence of chars to match should be non-empty.

There is no point in searching for an empty string and replace it with another empty string.

Valdi_Bo
  • 30,023
  • 4
  • 23
  • 41
  • it works but i'd like to not remove the lines with the digits – Andrew Jetun Apr 25 '20 at 13:32
  • @AndrewJetun: What's problem with this answer? It does what you want, doesn't it? – Toto Apr 25 '20 at 13:42
  • My solution does not remove lines with digits. The idea is: 1. Display the *Find* screen (Ctrl/F). 2. Select *Replace* tab. 3. Enter the regex into *Find what* field. 4. *Replace with* field leave empty. 5. Select *Regular expression* radio button. 6. Click *Find Next* to find the first match. 7. Click *Replace All*. 8. After replacement click *Close*. – Valdi_Bo Apr 25 '20 at 17:28
0

correction: try this:

([^0-9| ]+) 

this will surely work!!!

open the file in notepad++ press CTRL+H check the box with search mode regular expression and put in the above regex and click replace all test image

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
Nikhil S
  • 3,786
  • 4
  • 18
  • 32
  • Why do you add parenthesis? Why do you separate `0-9` and space in 2 character class? How do you use this regex? They want to remove every character that is not digit or space. How does this answer the question? – Toto Apr 25 '20 at 11:59
  • @Toto corrected!!! – Nikhil S Apr 25 '20 at 14:15
  • @Andrew Jetun its wokring right !!!!! give it a green tick. community will get help!!! – Nikhil S Apr 28 '20 at 12:03
  • Try this ...... find what: `[^\d\n]*` and replace all with: `nothing` this won't remove lines as intended ..... – Haji Rahmatullah Apr 11 '21 at 13:29