首页 > 解决方案 > 如果至少有两个或多个大写字母我想将它们更改为小写

问题描述

如果至少有两个或多个大写字母,我想将它们更改为小写,第一个字母大写。我使用记事本++

例子

FLAT TOP FADE 

Styling winglet curls can sometimes be a challenge

Flat top fade  

Styling winglet curls can sometimes be a challenge

或者

Flat Top Fade  

Styling winglet curls can sometimes be a challenge

标签: notepad++

解决方案


  • Ctrl+H
  • 查找内容:(?<![A-Z])([A-Z])([A-Z]+.+$) # 第一个选项或
  • 查找内容:(?<![A-Z])([A-Z])([A-Z]+)(?![A-Z]) # 第二个选项
  • 用。。。来代替:$1\L$2
  • 检查匹配案例
  • 检查环绕
  • 检查正则表达式
  • 取消选中. matches newline
  • Replace all

解释:

第一个选项

(?<![A-Z])      # negative lookbeahind, make sure we haven't upper before
([A-Z])         # group 1, 1 upper
(               # group 2
  [A-Z]+        # 1 or more upper
  .+            # 1 or more any character but newline
  $             # end of line
)               # end group 2

或第二个选项

(?<![A-Z])      # negative lookbeahind, make sure we haven't upper before
([A-Z])         # group 1, 1 upper
([A-Z]+)        # group 2, 1 or more upper
(?![A-Z])       # negative lookahead, make sure we haven't upper after

替换: 两个选项相同

$1          # content of group 1 (the first upper letter)
\L$2        # lowercased the content of group 2, the other letters

屏幕截图(第一个选项):

在此处输入图像描述

屏幕截图(第二个选项):

在此处输入图像描述


推荐阅读