0

I would like to know how I can merge lines within Notepad++ using regex, with certain tags that start with the character. For example:

1|AAA
BBB
CCC
6|DDD
1|EEE
FFF
6|GGG
1|HHH
UUU
III
6|OOO

The expected result:

1|AAABBBCCC6|DDD
1|EEEFFF6|GGG
1|HHHUUUIII6|OOO

The new records start with 1| line and end with 6| line. Thanks

ZerO
  • 74
  • 6
  • Have you tried anything yet? – Wiktor Stribiżew Oct 27 '15 at 09:47
  • yeah, I tried to merge rows. But cannot merge with certain tags. I am just new fresher in regex. could you give me some links to learn from basic in regex? Thanks – ZerO Oct 27 '15 at 10:18
  • 1
    I do not know your level of regex knowledge :) so that I can only suggest doing all lessons at [regexone.com](http://regexone.com/), reading through [regular-expressions.info](http://www.regular-expressions.info), [regex SO tag description](http://stackoverflow.com/tags/regex/info) (with many other links to great online resources), and the community SO post called [What does the regex mean](http://stackoverflow.com/questions/22937618/reference-what-does-this-regex-mean). – Wiktor Stribiżew Oct 27 '15 at 10:19
  • : ) Thank you so much. Junior level, of course. : D – ZerO Oct 27 '15 at 10:39

2 Answers2

0
\r\n(?=(?:(?!1\|)[\s\S])*?6\|)

You can this and replace by empty string.See demo.

https://regex101.com/r/vP2zF2/3

vks
  • 63,206
  • 9
  • 78
  • 110
  • Thank you vks. could you give me an explaination about using g(global) and m(multi-line) in Notepad++. I dont know why defining gm in notepad++. thanks. – ZerO Oct 27 '15 at 10:25
  • @ZerO you dont need those in `notepadd++`. – vks Oct 27 '15 at 10:26
0

You could just use this:

\s(?=[^1])

Regex Demo Here


Also tested in Notepad++

enter image description here

SierraOscar
  • 16,918
  • 4
  • 36
  • 59