使用 lookbehind 来测试结尾

可以在图案的末尾使用 lookbehind 以确保它以某种方式结束或不结束。

([a-z ]+|[A-Z ]+)(?<! ) 仅匹配小写或仅大写单词的序列,同时排除尾随空格。