well, if the string is exactly how you have it, then something like this would do :
$var="mailto:[EMAIL PROTECTED])"; if(preg_match("/^(\S+)\s.+/",$var,$match)){ $name=$match[1]; }
Of course, that would exclude those addresses that might have two names, like "Tim Traver [EMAIL PROTECTED]"
In order to get that one, you might do something like this :
$var="Tim Traver [EMAIL PROTECTED]"; if(preg_match("/^(.+)\s\{.+/",$var,$match)){ $name=$match[1]; }
That would get anything before the bracket, excluding the space...
Hope that helps...
Tim.
At 08:10 PM 3/28/2004, Jason Williard wrote:
I am trying to use preg_match to pull a specific piece of a variable. However, I don't have enough experience with the syntax to be able to figure this out.
The variable looks like: "John {mailto:[EMAIL PROTECTED])" All I need is the name, John. The rest can be discarded. How would I pull that bit out?
Thanks, Jason
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
SimpleNet's Back ! http://www.simplenet.com