HDFilmMaker2112 Posted June 22, 2011 Share Posted June 22, 2011 Could somebody break down for me what the below actually does? I found the snippet on php.net. I've read up a little bit on reg expressions but it's still a little unclear to me. I get the [] means don't include that character. But then how does the [a-zA-Z0-9._-] work? preg_match('/^[^@]+@[a-zA-Z0-9._-]+\.[a-zA-Z]+$/', $email) Link to comment https://forums.phpfreaks.com/topic/240077-preg_match-for-email-address/ Share on other sites More sharing options...
reksss Posted June 22, 2011 Share Posted June 22, 2011 [] - This is the Character class. U must need to specify all conditions by using []. [a-zA-Z0-9._-] It means ur allowing any lowercase[a-z], uppercase[A-Z], any numbers[0-9], special characters[._-]. Link to comment https://forums.phpfreaks.com/topic/240077-preg_match-for-email-address/#findComment-1233203 Share on other sites More sharing options...
HDFilmMaker2112 Posted June 22, 2011 Author Share Posted June 22, 2011 Alright what do the plus signs do? Link to comment https://forums.phpfreaks.com/topic/240077-preg_match-for-email-address/#findComment-1233249 Share on other sites More sharing options...
TeNDoLLA Posted June 22, 2011 Share Posted June 22, 2011 Plus sign means 1 or more occurances of [a-zA-Z0-9._-] pattern, then theres \. which means dot before the email ending or extension (.com/org etc), then [a-zA-Z]+$ means alphabets 1 or more at the. [^@] at the start means the email cannot start with @-sign, ^-sign inside pattern is a negation. That is if I remember it correctly. Theres a great regexp tutorial here: http://www.regular-expressions.info/ . It would be much more beneficial for you to understand how they work instead of everytime you face a regular expression you ask people to explain it bit by bit. Don't think thats even a correct regexp for email(?) I might be mistaken also though. Link to comment https://forums.phpfreaks.com/topic/240077-preg_match-for-email-address/#findComment-1233256 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.