Vadimas Sizikovas
Vadimas Sizikovas

Reputation: 74

Replacing separator

Is it possible to replace last separator | character with space on each row using notepad++ only if the | is between the name and secondname?

I have:

number|surname|name
number|surname|name|secondname

I need:

number|surname|name
number|surname|name secondname

Upvotes: 0

Views: 50

Answers (3)

vks
vks

Reputation: 67988

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

Try this.Replace by $1$2$3$4.See demo.

http://regex101.com/r/oE6jJ1/29

Upvotes: 0

Jerry
Jerry

Reputation: 71598

Disclaimer: I'm making the assumption that you have a pipe delimited file that you need to 'fix' so that there is a correct amount of columns and that there are 3 columns, with the problem being that the 3rd column can sometimes contain pipe(s).

For that, you can use the regex:

(?:^(?:[^|\n]*\|){2}|(?!^)\G)[^|\n]*\K\|

And replace with space.

regex101

Upvotes: 1

Amit Joki
Amit Joki

Reputation: 59292

From your comments, you can use this regex

((?:\w+\|){2})(\w+)\|(\w+)

and replace with $1$2 $3

DEMO

Upvotes: 3

Related Questions