I'm trying to validate my input in PHP, how to check if @username exists in the string in the following valid formats in UTF8?
Valid:
- "Hello @username"
- "Hello@username"
- "Hello @username how are you?"
Invalid
- "Hello username"
- "Hello @usernamehow are you?"
The following code works, but claims "@usernamehow" is valid when searching for "@username"
$userMentioned = substr_count($text, $username);