pregex matching for valid email
Moderator: General Moderators
Well that's quite allright, i was fiddling with different types of domains...and that's not causing the problem thanks though... it's currently set {2,4} just in case, that is minimum 2 maximum 4.nielsene wrote: Your {3,4} stops it from matching all the two character country codes. It only matches the org/com/mil/net/info/coop/edu type top levels.
In response to m3rajk I am not sure but does your expression take in consideration [0-9] matches, i don't see a \d so i ask.
Basically all i am trying to do is what PHP bb already does though i would like to figure it out with your help and not exactly just copy n' paste.
My futile attempt to get it working is the following, but as you see it's very lengthy nad i have alot of stuff repeated. Plus it only recognizes links like: me@myself.whatever after the'@' i would like it to recognize 3 things.
Code: Select all
$str = ereg_replace( "^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*.[0-9a-z]([-.]?[0-9a-z])*.[a-z]{2,4}$", "<a href="mailto:\\0">\\0</a>", $str );- Heavy
- Forum Contributor
- Posts: 478
- Joined: Sun Sep 22, 2002 7:36 am
- Location: Viksjöfors, Hälsingland, Sweden
- Contact:
But it is...m3rajk wrote:... and \w is perl. perl is not local dependant.
See http://www.php.net/manual/en/pcre.pattern.syntax.php:
PHP Manual wrote: A "word" character is any letter or digit or the underscore character, that is, any character which can be part of a Perl "word". The definition of letters and digits is controlled by PCRE's character tables, and may vary if locale-specific matching is taking place (see "Locale support" above). For example, in the "fr" (French) locale, some char- acter codes greater than 128 are used for accented letters, and these are matched by \w.