Notepad ++ Regex finding a second appearance of a character and move it to the new line
Good day Guys
I am not familiar with regex, Im using notepad++ trying to clean some data i received. Is there a way to find a second appearance of a character and place it on a new line.
I neeed to find the second appearance of the number ‘1’ and put it into a new line.
You may try the following:
(\d+): find a sequence of digits at least one character long. Remember it for further use.
(\|.*?): find a Pipe character followed by an arbitrary sequence of characters but make it a short as possible. Remember for further use.
\|\1: find a Pipe character followed by the first captured sequence.
(\|.*): grab the remainder of the current line. Remember it for further use.
Now we have stored the entire line and can start rebuilding it:
\1: first captured sequence (first set of digits)
\2: second captured sequence
\r\n: new line
\1: first captured sequence again
\3: third captured sequence (remainder of line)
See http://www.boost.org/doc/libs/1_57_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html and http://www.boost.org/doc/libs/1_57_0/libs/regex/doc/html/boost_regex/format/perl_format.html for more information about RegExes in NPP.