Substr() and preg_match()

I can’t understand how to use either of these functions in PHP. Bother to help anybody?

whatchya trying to do exactly? can you be more specific?

http://www.php.net/preg_match
http://www.php.net/substr

I actually understood the substr function. I’m trying to use preg_match() for checking an email format.

<?php

$email = "[email protected]";

if ( !preg_match("/^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/", $email ) )
echo 'E-mail is invalid!';

?>

I got the regex pattern off a site i googled up, I’m too dumb to write my own, lol…

those kind of things scares me…

haha! well, mind explaining it a bit ahmed?

He got it off a site…

Basically it’s a pattern of symbols :

("/^w(?:w|-|.(?!.|@))@w(?:w|-|.(?!.)).w{2,3}/

Well Duh… But the symbols can mean different things… The ? marks with a : next to it I believe are conditional statments set inside of a list of patterns…I know that the w represents an escape sequence that draws forth from the current locale computer’s character map.

But… Most of the othger symbols draw a blank for me… And I’m not quite sure I want to look it up to figure it out right now :wink:

I wish things were more clear

well they are called regular expressions and they are a bit difficult to understand at first… here is a link to a really good tutorial about using them…
http://www.tote-taste.de/X-Project/regex/index.php

hey thanks jubba! I got more than I needed. Ain’t that some christmas present eh? :smiley:

Hot ****… Pretty good link there Vash :slight_smile: I knew some commands but now I know em all! :smiley:

“/^[-_a-z0-9]+(.[-_a-z0-9]+)@[-a-z0-9]+(.[-a-z0-9]+).[a-z]{2,6}$/i”

There ya go :smiley: That’s great!