tags:

views:

26

answers:

1

Using the following regex with the ExtJS library, the intention is to only allow spaces, dollar signs, underscores, alpha and numeric characters. However, for some reason, the vertical bar/ pipe character is allowed as well. I hope someone can tell me what I am missing here. Am I inadvertently escaping one of the vertical bars?

maskRe:/^[a-z|A-Z|0-9|$|_ ]$/

Thank you kindly for your time!

+2  A: 

You don't need the vertical bars inside your character class. Try the following instead:

maskRe:/^[a-zA-Z0-9$_ ]$/
Phil Ross
…which usually can be shortened to: `/^[\w$ ]+$/`. I take it as read that the OP actually wants to allow more than one character, so note the quantifier.
Tomalak
Wonderful, Phil, I thought I had tested that out before, but must have had another character off. I'm new to regex, but certainly realizing how powerful it can be!
Tim