PartyPooper Posted November 26, 2005 Posted November 26, 2005 Hi all, I know that there are various implementations of RegEx's floating around and was just wondering if the \w and \W matching characters are suppose to be equivalent to [a-zA-Z0-9_] and [^a-zA-Z0-9_] respectively (like in python) or just [a-zA-Z_] and [^a-zA-Z_] ? Cheers
LxP Posted November 26, 2005 Posted November 26, 2005 (edited) The help file suggests that \w matches A-Z, a-z and _ only.Edit: Python is weird. Edited November 26, 2005 by LxP
PartyPooper Posted November 26, 2005 Author Posted November 26, 2005 Yeah, figured that after the expression failed. Was trying to limit the characters to valid filename ones and have got [^a-zA-Z0-9_-]. Just gotta figure out how to allow a space character now.P.S. I hate regex's - confuse the hell outta me everytime
PartyPooper Posted November 26, 2005 Author Posted November 26, 2005 Well that was easier than I thought - just changed it to [^ a-zA-Z0-9_-] and it seems to work
LxP Posted November 26, 2005 Posted November 26, 2005 I'm not sure that the hyphen will be matched (which seems to be what you want). Try escaping it:[^ a-zA-Z0-9_\-]
PartyPooper Posted November 26, 2005 Author Posted November 26, 2005 It matched ok here as is. The space didn't when I added it to the end but it did when I moved it to the beginning of the expression. Maybe it has something to do with precedence?
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