在Notepad++中,在“查找和替换”对话框中启用正则表达式模式,然后查找:
(?<=<p>)(.)
并替换为:
\U\1
要解释要匹配的模式:
(?<=a)b # A positive lookbehind, i.e. match all b that immediately follow a, but
# don't match the "a" itself.
(.) # Find any character (i.e. "."), and capture it.
(?<=a)(.) # Find any character that immediately follows a, and capture it.
更换:
\1 # The first captured substring in each match.
\Ux # Convert x to upper case.
\U\1 # Convert the first captured substring in each match to upper case.
请注意,这将尝试转换第一个
性格
至大写。如果
<p>
以及你想要大写的字母,你可以这样做:
(?<=<p>)([^A-Za-z]*)(.)
# [^x] Matches any character that is not x.
# [^A-Za-z] Matches any character that is not one of the upper case
# or lower case letters.
# x* Matches zero or more consecutive x.
# [^A-Za-z]* Matches zero or more consecutive characters that are not
# upper case or lower case letters.
并替换为
\1\U\2 # The first captured substring (any non-letter characters
# that immediately follow <p>) followed by the second captured
# substring (the first letter that appears after <p>), which
# is converted to upper case.
要找到的模式是:“匹配(和捕获,在捕获组1中)紧跟其后的任何非字母字符
<p>
,然后匹配(和捕获,在捕获组2中)紧跟在非字母字符之后的第一个字符(当然,必须是我们希望确保为大写的字母)
*
,当后面没有非字母字符时,也会产生匹配
<p>
,在这种情况下,捕获组1将只保存一个空字符串。