有没有办法改变现有分隔符之间的分隔符。
例子:
文本:
"20;05;01";KT;1;467;331;1360
我想将其更改为:
"20,05,01";KT;1;467;331;1360
答案1
您需要进行搜索/替换(ctrl+ h),并将搜索模式设置为正则表达式。
搜索模式:"(.*);(.*);(.*)"(.*)
替换模式:"\1,\2,\3"\4
答案2
这对于双引号内的任意数量的分号都有效。
- Ctrl+H
- 找什么:
(?:"|\G)(?:(?![;"]).)*\K;(?=.*?")
- 用。。。来代替:
,
- 查看 环绕
- 查看 正则表达式
- 取消选中
. matches newline
- Replace all
解释:
(?:"|\G) # non capture group, a double quote OR restart from last match position
(?: # non capture group
(?![;"]) # negative lookahead, make sure the next character is not semicolon or double quote
. # any character
)* # end group, may appear 0 or more times
\K # forget all we have seen until this position
; # semicolon
(?=.*?") # positive lookahead, make sure we have a double quote after
截图(之前):
截图(之后):