Regular Expression Question

  • Thread starter Thread starter Axel Dahmen
  • Start date Start date
A

Axel Dahmen

Hi,

I want a regular expression to be any word character except "1".
Unfortunately I can't think of a pattern to use. Although it could be
/[a-zA-Z_02-9]/ I guess there must be a Unicode-proof version using /\w/.
Anyone?

Your help is quite appreciated.

Best regards,
Axel Dahmen
 
I want a regular expression to be any word character except "1".

[^\W1]

This uses a double-negative. It means "Don't match any character in the
list: non-word characters, and the digit "1". Essentially, this mean that
any word character matches, because it is not a non-word character, but
nothing else does, because it *is* a non-word character, and that even
though the digit "1" is a word character, it doesn't match explicitly.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
 
Great! Didn't know that character groups where allowed within []..

Thanks! :)
Axel

-------------------
Kevin Spencer said:
I want a regular expression to be any word character except "1".

[^\W1]

This uses a double-negative. It means "Don't match any character in the
list: non-word characters, and the digit "1". Essentially, this mean that
any word character matches, because it is not a non-word character, but
nothing else does, because it *is* a non-word character, and that even
though the digit "1" is a word character, it doesn't match explicitly.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
We got a sick zebra a hat,
you ultimate tuna.


Axel Dahmen said:
Hi,

I want a regular expression to be any word character except "1".
Unfortunately I can't think of a pattern to use. Although it could be
/[a-zA-Z_02-9]/ I guess there must be a Unicode-proof version using /\w/.
Anyone?

Your help is quite appreciated.

Best regards,
Axel Dahmen
 
Back
Top