[英]javascript regular expression allow name with one space and special Alphabets
how to write regular expression allow name with one space and special Alphabets? 如何编写正则表达式,允许名称带有一个空格和特殊字母? I tried with this
[a-zA-Z]+(?:(?:\\. |[' ])[a-zA-Z]+)*
but not working for me, 我尝试使用此
[a-zA-Z]+(?:(?:\\. |[' ])[a-zA-Z]+)*
但对我不起作用,
example string Björk Guðmundsdóttir 示例字符串BjörkGuðmundsdóttir
You may try something along these lines: 您可以尝试以下方法:
^(?!.*[ ].*[ ])[ A-Za-zÀ-ÖØ-öø-ÿ]+$
The first negative lookahead asserts that we do not find two spaces in the name. 首次出现负先行断言,我们没有找到名字两个空格。 This implies that at most one space is present (or no spaces at all).
这意味着最多存在一个空间(或根本没有空间)。 Then, we match any number of alphabets, with most accented letters included.
然后,我们将匹配任意数量的字母,其中包括最强调的字母。 Spaces can also be matched, but the lookahead would already ensure that at most one space can be present.
空间也可以匹配,但是超前已经可以确保最多存在一个空间。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.