Warning: preg_match (): No ending delimiter '^'

2

You're giving this error:

  

warning: preg_match (): No ending delimiter '^' found in /home/j17oloba/public_html/libs/lib.php on line 536

function lib_checkemail($email) 
{
if(preg_match("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,3}$", $email, $check)) 
{
    
asked by anonymous 19.01.2015 / 17:28

2 answers

3

It is necessary to place delimiters in the regular expression, thus:

if(preg_match("/^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,3}$/", $email, $check))

A delimiter can be any non-alphanumeric character that is neither an inverted slash \ nor a space. Examples: / , # , ~ , % .

More information: Delimiters

    
19.01.2015 / 17:34
2

You need to add delimiters in your regular expression.

Example using # at start and end:

"#^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\.[a-z]{2,3}$#"
    
19.01.2015 / 17:33