开发者

Regular Expression to match 6-15 alphanumeric characters plus symbols above 1-8 keys on keyboard

I'm trying to get a regular expression that allows between 6 - 15 characters and can be a-zA-Z0-9 and the symbols above the numbers 1-8 on a key开发者_如何学Pythonboard.

Here's what I have but it doesn't work.

'/^[a-zA-Z0-9-_][\!\@\#\$\%\^&\*]{5,16}+$/'


you have two different sets within brackets. Basically the expression says "1 of a-zA-Z0-9-_" followed by 5-16 of special characters. Combine them into the same set of brackets and you're all good.

Something like the following:

'/^[a-zA-Z0-9-_\!\@\#\$\%\^&\*]{5,16}$/'


Try this:

^[\w-!@#$%^&*]{6,15}$

As \w means [a-zA-Z_0-9]


'/^[a-zA-Z0-9-_!@#$%^&*]{5,16}$/'


/^[\w\!\@\#\$\%\^&\]{6,15}$/

That is what it would be in Perl.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜