在Notepad++中,在大写字符前添加逗号。

huangapple go评论54阅读模式
英文:

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:    (?&lt;=[a-z])\s*(?=[A-Z])
Replace: ,

<h2>Demo</h2>

The regex pattern used here says to match:

  • (?&lt;=[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

huangapple
  • 本文由 发表于 2023年2月19日 14:33:49
  • 转载请务必保留本文链接:https://go.coder-hub.com/75498406.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定