英文:
Regex: Replace with value inside quotation marks and ignore if just quotation marks
问题
test dd,test,"",test,tes_d
英文:
I have this:
"test dd","test","","test","tes_d"
I would like this:
test dd,test,"",test,tes_d
It works with "([^"]*)", but it replaces third value ("") with empty string.
答案1
得分: 1
你可以使用以下正则表达式:
("")|"([^"]+)"
替换为:
$1$2
详细信息:
("")- 第一组 ($1):""字符串|- 或"([^"]+)"- 一个",然后任意一个或多个不是"的字符(捕获到第二组,$2),然后是一个"。
英文:
You can use
("")|"([^"]+)"
Replace with $1$2, see the regex demo.
Details
("")- Group 1 ($1):""string|- or"([^"]+)"- a", then any one or more chars other than"(captured into Group 2,$2) and then a".
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论