Error Delimiter must not be alphanumeric or backslash [duplicate]

0

Good afternoon guys from stackoverflow. Is there a way to do this? I've been trying, using this way:

for($i = 0; $i < count($array); $i++){
        if(preg_match( "\d{1,2}/\d{1,2}/\d{4}$" , $array[$i] )){
            echo 'true';
        }else{
            echo 'false';
        }
    }

It's been bugging:

  

Delimiter must not be alphanumeric or backslash in C: \ wamp \ www \ ecoprintQ \ ecoLicenseLayout \ json \ data-partners-r epots.php on line 14

Does anyone know how to do this?

    
asked by anonymous 18.04.2017 / 20:54

1 answer

2

The delimiters are missing, the preg functions require this and may also be missing ^ in regex \d{1,2}/\d{1,2}/\d{4}$ , so #^\d{1,2}/\d{1,2}/\d{4}$# :

for($i = 0; $i < count($array); $i++){
    if(preg_match( "#^\d{1,2}/\d{1,2}/\d{4}$#" , $array[$i] )){
        echo 'true';
    }else{
        echo 'false';
    }
}

Understand what the delimiters are and how they work at PCRE: link

    
18.04.2017 / 21:01