带有 jquery 和重音字符的正则表达式
我正在寻找一个正则表达式来验证输入: 在法国,我们可以在名称中使用重音字符,但我找不到任何可以使用的字符。 请您帮我找到如何使用正则表达式: -任何字母 - 任何带重音的字母 -空格 - 和符号“-”(不带引号)
我尝试过类似的方法,但它似乎不起作用.. var regealpha =/[^A-Za-z0-9ÀÁÁääàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ]/;
感谢您的帮助(抱歉我的英语不好……我是一只青蛙^^)
i'm looking for a regular expression to validate an input :
in France, we can use accented characters in name, and i don't find anything i can use.
please, can you help me to find how to do a regular expression for:
-any letter
-any accented letter
-spaces
- and the sign "-" (without quotes)
i've try something like but it don't seem to be working..
var regealpha =/[^A-Za-z0-9ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ]/;
thx for help (and sorry for my poor english... i'm a froggy ^^ )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
也许您想使用
\p{L}
(如此处所述),它匹配一个 unicode 字母。Maybe you want to use
\p{L}
(as described here), which matches a unicode letter.JavaScript 似乎没有很好的国际化选项。符号 \w 将为您提供所有 [A-Za-z0-9_],但除此之外您还需要规定自己的字符。
看来你们关系很亲密啊。以下正则表达式应该适合您:
查看它在这个 jsfiddle 上的工作:
http://jsfiddle.net/jameswiseman /3H2mJ/1/
您将看到正则表达式替换了输入字符串中的所有内容<代码>“0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyzÀÁÂàääàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ"与“z”。
编辑
我认为这就是您所需要的:
它会告诉您是否有字符不在上述集合中。所以
还要看看 this JSFiddle
我知道它很长,但如果是这样的话需要的话你应该使用它。
JavaScript doesn't seem to have good internationalization options. The symbol \w will give you all [A-Za-z0-9_], but you'll need to stipulate your own chars in addition to this.
You seem to be quite close. The following regex should work for you:
See it working at this jsfiddle:
http://jsfiddle.net/jameswiseman/3H2mJ/1/
You'll see that the regex replaces everything in the input string
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ"
with 'z'.EDIT
I think this is what you need:
It will tell you if there are characters NOT in the above set. So
Also have a look at this JSFiddle
I know it is long, but if that is what is needed then then you should use it.