-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 ...

Swader
  • 11,387
  • 14
  • 50
  • 84
  • 1
    I'd love it if those who downvoted this explained themselves a bit so I don't make the same mistake again. – Swader Apr 07 '12 at 12:05

1 Answers1

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])?/