0

$hey = 'stringand8723984';

if (preg_match('/^[a-zA-Z0-9]+$/', $hey)) 
{
  return true;
}
else
{
    return false;
}

I am trying to better understand regex and I understand the "[a-zA-Z0-9]" part is letters and numbers capital and small case. But what is "+$" and "^"

Would help a lot... tried reading documentation but it was confusing.

  • `^` means that the match have to start at the beggining of string you matching, `$` is exact oposite, if you didn't had it there string like `@stringand8723984@blah` would match also, the `+` is qunatifier telling that any char from set in [] have to be peresent at least once or more times. take a loot at https://regex101.com/ best website about regular expression i know about, if you type your regular expression there you will see explanation of every single thing – Kazz Jun 16 '20 at 02:46

0 Answers0