[thelist] Quick and dirty Reg Ex question

Matt Warden mwarden at gmail.com
Wed Oct 26 14:25:50 CDT 2005


On 10/26/05, Iain <iain at firelightning.com> wrote:
> ^[a-zA-Z0-9_.-]+@[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\.[a-zA-Z0-9]{2,})*$
>
> Why does this pattern test correctly in Javascript, but not in PHP?

If the RegEx is in a double-quoted string, I believe you'll have to
quote your \ character.

preg_match("^[a-zA-Z0-9_.-]+@[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*(\\.[a-zA-Z0-9]{2,})*$",
...);

--
Matt Warden
Miami University
Oxford, OH, USA
http://mattwarden.com


This email proudly and graciously contributes to entropy.



More information about the thelist mailing list