2

In NotePad++ how do I turn this:

GingeredRovinsky7|NTDc4MAODY3Mg|

into this:

GingeredRovinsky7=NTDc4MAODY3Mg

I know I can do a find and replace and replace the first | with =

However I need to strip the last | from each line as well.

How do I do this?

migrated from stackoverflow.com Aug 15 '11 at 4:25

This question came from our site for professional and enthusiast programmers.

4

If every line is going to consist of exactly two | characters in that format, I should think this regex find-and-replace will do it.

Find all:

^([^|]*)\|([^|]*)\|$

Replace all with:

\1=\2

3

Notepad++ supports extended and regular expression search and replace. Using the extended search and replace you could do this in two passes.

In the first pass replace the trailing | by searching for |\r and replacing with \r:

enter image description here

In the second pass we replace the middle | by doing a normal search and replace.

This of course assumes that your line ends are \r\n.

2

You can use a regular expression at the replace dialog.

Find:

.{1}$

Replace with nothing Then just select Replace All

Full options are: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy