英文:
Add comma before uppercase character in notepad++
问题
我有一个包含文本的文件:StackOverFlow IsTheBest
我想要这个结果:Stack,Over,Flow ,Is,The,Best
(在每个大写字母前加逗号)
英文:
I have a text file containing: StackOverFlow IsTheBest
I want this result: Stack,Over,Flow ,Is,The,Best
(Add comma before every uppercase character)
I searched but didn't see any good results.
I also don't know how to do that.
答案1
得分: 0
我们可以尝试使用正则表达式的环视进行替换:
查找: (?<=[a-z])\s*(?=[A-Z])
替换: ,
[<h2>Demo</h2>][1]
这里使用的正则表达式模式表示:
- `(?<=[a-z])` 断言之前是小写字母
- `\s*` 匹配可选的空白字符
- `(?=[A-Z])` 断言之后是大写字母
[1]: https://regex101.com/r/sBVEO0/1
英文:
We can try doing a regex replacement using lookarounds:
Find: (?<=[a-z])\s*(?=[A-Z])
Replace: ,
The regex pattern used here says to match:
(?<=[a-z])
assert that what precedes is a lowercase letter\s*
match optional whitespace characters(?=[A-Z])
assert that what follows is an uppercase letter
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论