Re: What this means "(\w|-)+@\w"? [message #174785 is a reply to message #174784] |
Thu, 07 July 2011 15:39 |
Michael Fesser
Messages: 215 Registered: September 2010
Karma:
|
Senior Member |
|
|
.oO(zhang yun)
> I have some problems in regular expression, here is code :
> […]
>
> I don't know the exactly meaning of "(\w|-)+@\w", could you help me
> figure out its meaning? I'm new to posix standard.
(\w|-) any word char (see manual for details [1]) or a minus sign
+ any number of the above, but at least one
@ a literal
\w a single word char
So this matches at least one, but up to any number of word chars and
minus signs, followed by a literal '@', followed by a single word char.
An alternative way of writing (\w|-) would be [\w-], which replaces the
OR-operator by a character class, that includes word chars and the minus
sign.
HTH
Micha
[1] http://www.php.net/manual/en/regexp.reference.escape.php
|
|
|