Using Notepad++ Regex to Find and Replace Only Par

2019-03-09 20:06发布

I have a file with a some comma separated names and some comma separated account numbers. So the names will always be something like "Dow, John" and the numbers like "012394,19862". Using Notepad++'s Regex Find features, I'd like to change all the ','s between the numbers into '|'s.

Basically turn:

12345,09876
13568,08642

into

12345|09876
13568|08642

I've been using [0-9], to find the commas, but I can't get it to properly leave the last digit of the number and replace just the comma.

Any ideas?

3条回答
我欲成王,谁敢阻挡
2楼-- · 2019-03-09 20:53

Search for ([0-9]), and replace it with \1|. Does that work?

ゆ 、 Hurt°
3楼-- · 2019-03-09 20:55

use this regex

(\d),(\d)

and replace it with

$1|$2

OR

\1|\2
查看更多
霸刀☆藐视天下
4楼-- · 2019-03-09 21:00

(?<=\d), should work. Oddly enough, this is only working if I use replace all, but not if I use replace single. As an alternative, you can use (\d), and replace with $1|

登录 后发表回答