Update: I changed the code on how the mention works with regex.
$pattern = '/(?<!\w)' . preg_quote($username, '/') . '(?!\w)/i';
if(preg_match($pattern, $post_to_scan) === 1){
}
This code works on with @sign, username (case insensitive) and will not work if username is inside a word string like "agbe" - "nagbenta".
@Agbe Let me know if you still get notification from those threads. Thanks.