我正在尝试从文本文件中的某个位置删除逗号。输入如下:
Y=6","~2807-1 Q12m. 任何骨头中的板、螺丝、杆或针 - 否"
我只想删除“Y=6”、“”和结尾双引号之间的逗号。如果我使用
(?<=Y=\d“,”)。*(?=“)
我可以隔离它们之间的部分,但却无法弄清楚如何只得到逗号。
答案1
- 寻找:
(?:Y=\d","|\G)[^,"]*\K,
- 代替:
NOTHING
解释:
(?: # start non capture group
Y=\d # literally Y= followed by 1 digit. You may want to use \d+ for 1 or more digits
"," # literally ","
| # OR
\G # restart form last match position
) # end group
[^,"]* # 0 or more any character that is not comma or double quote
\K # forget all we have seen until this position
, # a comma