KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My string of text looks like this: johndoe@domain.com (John Doe) I need to get just the part before the @ and nothing else. The text is coming from a simple XML object if that matters any. The code I have looks like this: $authorpre = $key->{"author"}; $re1 = '((?:[a-z][a-z]+))'; if ($c = preg_match_all ("/".$re1."/is", $authorpre, $matches)) { $author = $matches[1][0]; } Sometimes the username might have numbers or an underscore before the @ symbol, which is where the regex stops it seems.
Tags (comma-separated)
Save Edits
Cancel