我有近千行相同的结构,我必须编辑其中的一部分。
"650","4","The lenght of this part varies, Here's some commas, here, and, there"
"203","4","Now this is shorter, Don't edit these commas, here"
"102","4","Really short, More commas, incoming"
以上内容应编辑为这样,即添加撇号。
"650","4","The lenght of this part varies", "Here's some commas, here, and, there"
"203","4","Now this is shorter", "Don't edit these commas, here"
"102","4","Really short", "More commas, incoming"
如何选择第一个逗号“4”,? 我正在使用 Sublime Text 2,它支持正则表达式。
距离我上次需要正则表达式已经过去很多年了,所以请多多包涵。提前谢谢!
答案1
我还没有使用 Sublime Text 来执行正则表达式的查找和替换,但这在 Notepad++ 中有效,所以希望您能找到使用它的方法。
(.{5},.{3}?,.*?),
这将捕获第一部分,直到第三个逗号,然后您可以执行以下操作进行替换:
\1", "
这会将第一部分插入回原始字符串,然后用 替换逗号", "
。