javascript 这个正则表达式是什么意思 - “\p{Lu}”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25977309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does this regexp mean - "\p{Lu}"?
提问by Mika?l Mayer
I stumble across this regular expression in c# I would like to port to javascript, and I do not understand the following:
我在 c# 中偶然发现了这个正则表达式,我想移植到 javascript,但我不明白以下内容:
[-.\p{Lu}\p{Ll}0-9]+
The part I have a hard time with is of course \p{Lu}
. All regexp websites I visited never mention this modifier.
我有困难的部分当然是\p{Lu}
。我访问过的所有正则表达式网站都没有提到这个修饰符。
Any idea?
任何的想法?
回答by hwnd
These are considered Unicodeproperties.
这些被认为是Unicode属性。
The Unicode property \p{L}
— shorthand for \p{Letter}
will match any kind of letter from any language. Therefore, \p{Lu}
will match an uppercase letter that has a lowercase variant. And, the opposite \p{Ll}
will match a lowercase letter that has an uppercase variant.
Unicode 属性\p{L}
— for 的简写\p{Letter}
将匹配来自任何语言的任何类型的字母。因此,\p{Lu}
将匹配具有小写变体的大写字母。并且,相反的\p{Ll}
将匹配具有大写变体的小写字母。
Concisely, this would match any lowercase/uppercase that has a variantfrom any language:
AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz