-2

I am looking for a way in Notepad++ to find lines not containing any number and moving it to the previous line after adding a separator like "#"

moon  215466 
sun & stars world

the sea 345454 
sky @ 464654
cars 135456
school teachers

the result i want:

moon  215466#sun & stars world

the sea 345454 
sky @ 464654
cars 135456#school teachers

I am new to regex so i searched all questions and tried ^[^\d]$ and ^\D$ and /^[^0-9]*$/ it find the lines with no numbers but i can't move it to the previous line.

Thank you

twitter
  • 31
  • 3
  • it's a file contains more than 10000 lines so this is a samples of what i want to do not the exact words – twitter Jul 29 '19 at 23:49

2 Answers2

2

You can try the following:

enter image description here

If you write your text out, it will look something like this:

enter image description here

What you essentially want to do is to remove the CR (carriage return) and LF (line feed) characters if they are followed by a line containing no digits. The regex for a line containing no digits is ^(\D*)$ - please do ask if you need help understanding how it works. We then replace the CR + LF + Regex match with #\1 - # symbol and \1 references the contents of the first capturing group, which means the first set of parentheses in your search regex (line with no digits).

Result:

enter image description here

vs97
  • 5,765
  • 3
  • 28
  • 41
0

Maybe this expression,

(?m)(.*?@\s*\d+)\s*(.*?&.*)

with a replacement of

$1#$2

might work, not sure though.

DEMO

Reference

Notepad++ multiline regex

Community
  • 1
  • 1
Emma
  • 27,428
  • 11
  • 44
  • 69