-1

How do I turn this regexp

[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

from this site: http://www.regular-expressions.info/email.html

into a Perl compatible regexp required by PHP in the filter_var function under FILTER_VALIDATE_REGEXP?

If I just add it to the options as-is I get this error: filter_var() [function.filter-var]: Unknown modifier '+' in ...

4

1 回答 1

2

You need to wrap the expression with a delimiter (/ is most commonly used):

/[a-z0-9!#$%&'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/
于 2012-04-07T12:01:07.637 回答