Home All Groups Group Topic Archive Search About

Regular Expression Question

Author
10 Feb 2006 2:54 PM
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

Author
10 Feb 2006 3:43 PM
Kevin Spencer
> 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.


Show quote
"Axel Dahmen" <NO_SPAM@NoOneKnows.invalid> wrote in message
news:ulNYhHlLGHA.532@TK2MSFTNGP15.phx.gbl...
> 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
>
>
Author
10 Feb 2006 4:03 PM
Axel Dahmen
Great! Didn't know that character groups where allowed within []..

Thanks! :)
Axel

-------------------
Show quote
"Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> wrote in message
news:uplW$ilLGHA.1424@TK2MSFTNGP12.phx.gbl...
> > 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" <NO_SPAM@NoOneKnows.invalid> wrote in message
> news:ulNYhHlLGHA.532@TK2MSFTNGP15.phx.gbl...
> > 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
> >
> >
>
>

AddThis Social Bookmark Button