最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Does Javascript RegExp support POSIX expressions? - Stack Overflow

programmeradmin2浏览0评论

I have a password <input> box in a <form> element my html body

When a user click on the submit button in the sign up form, I can get javascript to determine whether the string the user typed in the password box is a combination of alphabet and/ or numbers by using the following code

$("#password1").val().match(new RegExp(/[a-zA-Z1-9]{1,}/));

However when I tried using the expression below, it returns "null" which gives me the impression that POSIX expressions are not supported in javascript... or is it somewhere along the line I am missing something?

$("#password1").val().match(new RegExp(/[[:alnum:]]{1,}/));

I have a password <input> box in a <form> element my html body

When a user click on the submit button in the sign up form, I can get javascript to determine whether the string the user typed in the password box is a combination of alphabet and/ or numbers by using the following code

$("#password1").val().match(new RegExp(/[a-zA-Z1-9]{1,}/));

However when I tried using the expression below, it returns "null" which gives me the impression that POSIX expressions are not supported in javascript... or is it somewhere along the line I am missing something?

$("#password1").val().match(new RegExp(/[[:alnum:]]{1,}/));
Share Improve this question asked Jul 7, 2015 at 23:07 repzerorepzero 8,4123 gold badges20 silver badges42 bronze badges 0
Add a comment  | 

2 Answers 2

Reset to default 14

Posix expressions such as :alnum: are not supported, though some other backslash-escaped character classes (like \w for word characters including alphanumeric characters and the underscore) are allowed.

POSIX character classes are not supported, but you can find JavaScript equivalents to them here:

http://www.regular-expressions.info/posixbrackets.html

发布评论

评论列表(0)

  1. 暂无评论