更新时间:2023-02-21 19:08:30
感谢此答案,我能够在最初认为不可能的情况下找到解决问题的方法.
Thanks to this answer, I was able to find a solution to your problem after initially thinking it wasn't possible.
在Notepad ++中执行此操作的方法是使用以下选项:
The way to do this in Notepad++ is to use the following options:
^([^:]+:)(([A-Z])|([a-z]))([^:]+)$
$1\L$3\E\U$4\E$5
^([^:]+:)(([A-Z])|([a-z]))([^:]+)$
$1\L$3\E\U$4\E$5
以下是此操作的GIF:
Here's a GIF of this in action:
查找内容字段的细分:
^
代表行的开头,结尾的$
代表行的结尾.这样可以防止它变得懒惰或换行.([^:]+:)
代表该行开头的字符,允许除:
之外的所有字符.这是组$1
(([A-Z])|([a-z]))
表示:
之后的第一个字符.如果除了大写或小写字母外,其他任何内容都将跳过该行.
$2
将是第一个字符,无论大小写如何.我们将在替代产品时忽略它.$3
如果是大写字母,将是第一个字符,否则$3
将为空.$4
如果是小写字母,将是第一个字符,否则$4
将为空.^
at the front of the Regular Expression represents the beginning of a line and $
at the end represents the end of a line. This prevents it from being lazy or wrapping to the next line.([^:]+:)
represents the characters at the beginning of the line, allowing all characters except :
. This is group $1
(([A-Z])|([a-z]))
represents the first character after the :
. If there is anything other than an upper or lowercase letter, it will skip the line.
$2
will be the first character, regardless of uppercase or lowercase. We'll ignore this in our replacement.$3
will be the first character if it is uppercase, otherwise $3
will be empty.$4
will be the first character if it is lowercase, otherwise $4
will be empty.替换为字段的明细:
$1
将是如上所述的第一组\L$3\E
将如上所述将组$3
转换为小写.\U$4\E' will convert group
$ 4`如上所述,为大写字母.$5
将是如上所述的最后一组$1
will be the first group as described above\L$3\E
will convert group $3
as described above to lowercase.\U$4\E' will convert group
$4` as described above to uppercase.$5
will be the last group as described above \L
和\U
分别表示开始转换为小写"或大写". \E
代表停止转换".由于$3
或$4
中只有一个包含第一个字符(另一个将为空白),因此仅在需要时才进行转换.
\L
and \U
stand for "beginning converting to lowercase" or "uppercase," respectively. \E
stands for "stop converting." Since only one out of $3
or $4
will contain the first character (the other will be blank), this converts only in the case we want.