Sunday 15 January 2012

notepad++ - Regex: remove lines not starting with a digit -


I am fighting with this problem with the help of a RegEx cheat sheet, how it is known how to do it, But let me leave ... I have to open this long file in Notepad ++ and would like to delete all the lines that do not start with a digit (0..9). I will use the Find / Replace functionality of N ++, I am just mentioning this because I'm not sure what the implementation of reggax is ... thanks ...

Example from the following text:

  1hello foo 2world bar 3!  

I would like to remove

  1hello 2world 3!  

No:

  1hello 2world 3!  

Search / replace on a regular expression.

You can assign that line to ^ [^ 0- 9]. * , but it will leave blank lines.

Use notepad ++ scintilla, and also use its regex engine to match them.

\ r and \ n never match because in Scintilla, regular expression searches are made per line, line (end-line characters have been stripped).

To clear those empty rows, the only way to choose extended mode is to choose, and \ n \ nchange it \ N if you are in window mode. So \ r \ n \ r \ nto \ r \ n


No comments:

Post a Comment