Using Notepad++ Regex to Find and Replace Only Part of Found Text

拟墨画扇 提交于 2019-12-18 10:54:07

问题


I have a file with a some comma separated names and some comma separated account numbers.
Names will always be something like Dow, John and numbers like 012394,19862.

Using Notepad++'s "Regex Find" feature, I'd like to replace commas between numbers with pipes |.

Basically :

turn:  Dow,John      into:  Dow,John
       12345,09876          12345|09876
       13568,08642          13568|08642

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

Any ideas?


回答1:


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




回答2:


use this regex

(\d),(\d)

and replace it with

$1|$2

OR

\1|\2



回答3:


(?<=\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|



来源:https://stackoverflow.com/questions/13164312/using-notepad-regex-to-find-and-replace-only-part-of-found-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!