常用的正则字母大小写转换

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/small__snail__5/article/details/88946566

示例1:将语句 test this sentence 转为大写

查找:^.*$

替换:\U$0

或------------

查找:^(.*)$

替换:\U\1 或 \U$1

示例2:将语句 TEST THIS SENTENCE 转为小写

查找:^.*$

替换:\L$0

或------------

查找:^(.*)$

替换:\L\1 或 \L$1

示例3:将语句 test this sentence 首字t母转为大写

查找:^.

替换:\U$0

或------------

查找:^(.)

替换:\U\1 或 \U$1

示例4:将语句 Test this sentence 首字T母转为小写

查找:^.

替换:\L$0

或------------

查找:^(.)

替换:\L\1 或 \L$1

示例5:将语句 test this sentence 每个单词首字母转为小写

查找:\b(\w)(\w*)\b

替换:\U$1\E$2 或 \U\1\E\2

总结:

1、\U 将匹配项转为大写(Upper) 
2、\L 将匹配项转为小写(Lower) 
3、\E 终止转换(End)

猜你喜欢

转载自blog.csdn.net/small__snail__5/article/details/88946566