John Curley Posted October 21, 2013 Share Posted October 21, 2013 I am an occasional user of javascript who relies on W3Schools reference and tutorials, which are great. However I recently wasted over an hour tracking a problem due to a misleading description in the Regexp Object reference, namely the line: [A-z] Find any character from uppercase A to lowercase z What isn't mentioned is that the regular expression [A-z] also finds other things like brackets, backslash and underline. This caused my program to complain about missing brackets. I suggest the problem line read instead: [a-zA-Z] Find any character from uppercase A to lowercase z Link to comment Share on other sites More sharing options...
MrFish Posted October 22, 2013 Share Posted October 22, 2013 (edited) Not sure what your problem is. It doesn't match brackets. http://jsfiddle.net/RPLUm/ Anything in a bracket says "match these characters". Then you define what characters you want to be matched. If you want to match actual brackets you need to escape the bracket with a backslash ''. Edited October 22, 2013 by MrFish Link to comment Share on other sites More sharing options...
justsomeguy Posted October 22, 2013 Share Posted October 22, 2013 He's pointing out that the pattern [A-z] matches more than just letters. It will match any ASCII character with a value between 65 and 122, which includes the symbols at 91-96. http://www.asciitable.com/ Link to comment Share on other sites More sharing options...
MrFish Posted October 22, 2013 Share Posted October 22, 2013 Oh. Well I didn't know that. Probably a good idea to include that in the tut if it's not already. You should probably just use w, d, s, etc. I've never actually used A-z or any variation of it. Just my opinion. Link to comment Share on other sites More sharing options...
thescientist Posted October 23, 2013 Share Posted October 23, 2013 that was the point of this post. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now