我使用属性Lt来匹配单词开头的大写字母(标题大小写(。
我的正则表达式(regex101.com(只是属性p{Lt}
,而我的测试字符串是Title Case
。
结果是:没有匹配。性质Ll和Lu给出了正确的结果。这种行为的原因是什么?
p{Lt}
只匹配Lt
类别中的Unuicode字母:
U+01C5 Dž Latin Capital Letter D with Small Letter Z with Caron
U+01C8 Lj Latin Capital Letter L with Small Letter J
U+01CB Nj Latin Capital Letter N with Small Letter J
U+01F2 Dz Latin Capital Letter D with Small Letter Z
U+1F88 ᾈ Greek Capital Letter Alpha with Psili and Prosgegrammeni
U+1F89 ᾉ Greek Capital Letter Alpha with Dasia and Prosgegrammeni
U+1F8A ᾊ Greek Capital Letter Alpha with Psili and Varia and Prosgegrammeni
U+1F8B ᾋ Greek Capital Letter Alpha with Dasia and Varia and Prosgegrammeni
U+1F8C ᾌ Greek Capital Letter Alpha with Psili and Oxia and Prosgegrammeni
U+1F8D ᾍ Greek Capital Letter Alpha with Dasia and Oxia and Prosgegrammeni
U+1F8E ᾎ Greek Capital Letter Alpha with Psili and Perispomeni and Prosgegrammeni
U+1F8F ᾏ Greek Capital Letter Alpha with Dasia and Perispomeni and Prosgegrammeni
U+1F98 ᾘ Greek Capital Letter Eta with Psili and Prosgegrammeni
U+1F99 ᾙ Greek Capital Letter Eta with Dasia and Prosgegrammeni
U+1F9A ᾚ Greek Capital Letter Eta with Psili and Varia and Prosgegrammeni
U+1F9B ᾛ Greek Capital Letter Eta with Dasia and Varia and Prosgegrammeni
U+1F9C ᾜ Greek Capital Letter Eta with Psili and Oxia and Prosgegrammeni
U+1F9D ᾝ Greek Capital Letter Eta with Dasia and Oxia and Prosgegrammeni
U+1F9E ᾞ Greek Capital Letter Eta with Psili and Perispomeni and Prosgegrammeni
U+1F9F ᾟ Greek Capital Letter Eta with Dasia and Perispomeni and Prosgegrammeni
U+1FA8 ᾨ Greek Capital Letter Omega with Psili and Prosgegrammeni
U+1FA9 ᾩ Greek Capital Letter Omega with Dasia and Prosgegrammeni
U+1FAA ᾪ Greek Capital Letter Omega with Psili and Varia and Prosgegrammeni
U+1FAB ᾫ Greek Capital Letter Omega with Dasia and Varia and Prosgegrammeni
U+1FAC ᾬ Greek Capital Letter Omega with Psili and Oxia and Prosgegrammeni
U+1FAD ᾭ Greek Capital Letter Omega with Dasia and Oxia and Prosgegrammeni
U+1FAE ᾮ Greek Capital Letter Omega with Psili and Perispomeni and Prosgegrammeni
U+1FAF ᾯ Greek Capital Letter Omega with Dasia and Perispomeni and Prosgegrammeni
U+1FBC ᾼ Greek Capital Letter Alpha with Prosgegrammeni
U+1FCC ῌ Greek Capital Letter Eta with Prosgegrammeni
U+1FFC ῼ Greek Capital Letter Omega with Prosgegrammeni
请参阅regex演示。
您想要的是bp{Lu}
,正则表达式将匹配任何前面没有单词char的大写字母。
请参阅regex演示。
根据你想在什么上下文中计算大写字母,正则表达式也可以看起来像
(?<!p{L})p{Lu}
-大写字母,前面没有任何字母(?<!S)p{Lu}
-一个大写字母,前面没有非空白字符