I have the following code:
preg_match('/@([^@ ]+)/', $image->caption->text, $matches)
and I wanted to basically find mentions in the line. However, the problem now is that it gets confused with the email address, so that it detects the email as a mention, so for example, if I have aksdjasd@yahoo.com, then this is considered a coincidence. I assume that I want to say here that there must be space in front of the @ sign. But how do I put this into this regular expression?
EDIT:
I also wanted to detect @mentions at the beginning of the line as well
source
share