Jump to content

Recommended Posts

Posted

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

Posted (edited)

The help file suggests that \w matches A-Z, a-z and _ only.

Edit: Python is weird. B)

Edited by LxP
Posted

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 B)

Posted

I'm not sure that the hyphen will be matched (which seems to be what you want). Try escaping it:

[^ a-zA-Z0-9_\-]

Posted

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?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...