参考信息:Notepad++ 正则表达式用空格大写替换大写字母 https://stackoverflow.com/questions/64602444/notepad-regex-to-replace-capitalised-case-words-with-space-capital
我需要添加一个要求,即匹配包含定义的前缀。
例如我想替换:
"name": "CapitalCaseWords"
"name": "AnotherStringSentence"
"ThisStringShouldntBeReplaced"
with:
"name": "Capital Case Words"
"name": "Another String Sentence"
"ThisStringShouldntBeReplaced"
在本例中,前缀是"name": "
.
我在用着(?<=[a-z])(?=[A-Z])
但它不适用于前缀。
正则表达式101示例:https://regex101.com/r/IpmOnK/2 https://regex101.com/r/IpmOnK/2
勾选“匹配大小写”选项后,您可以替换:
("name":\ "[A-Z][a-z]+|(?<!^)\G)([A-Z][a-z]+)
With:
\1 \2
Demo https://regex101.com/r/qpgt8o/1.
分解:
( # Start of 1st capturing group.
"name":\ " # Match the prefix (including the double quotation).
[A-Z][a-z]+ # Match an upper-case letter followed by one or more lower-case letters.
| # Or:
(?<!^)\G # Assert position at the end of the previous match.
) # End of 1st capturing group.
([A-Z][a-z]+) # 2nd capturing group matching an upper-case letter followed by
# one or more lower-case letters.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)