Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

preg_match(): No ending delimiter '^' found [duplicate]

Tags:

php

preg-match

Warning: preg_match(): No ending delimiter '^' found in .../functions/validations.php on line 29

The code:

 if (preg_match($mail_pat, $email, $components)) {

What and where do I make the edit?

like image 788
Simpel Avatar asked Apr 21 '13 09:04

Simpel


2 Answers

Perl based regex should be inside the delimeters.. "/your regex here/".. the deprecated POSIX regex were the one which did not require any delimeter.. eg ereg(")

like image 125
din din Avatar answered Oct 24 '22 09:10

din din


You must add delimiters to your regex:

if (preg_match('/' . $mail_pat . '/', $email, $components)) {

$mail_pat starts with a ^ but ends with another character, which causes the error since there are no matching delimiters.

like image 40
alexn Avatar answered Oct 24 '22 10:10

alexn