Error Delimiter must not be alphanumeric or backslash

Asked

Viewed 2,149 times

1

Good afternoon, stackoverflow crew. Is there a date in an array? I’ve been trying, using it like this:

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';
        }
    }

Only you’ve been making mistakes:

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

Someone knows how to do it?

  • Who mistakes? Error of parse? Returns something like true shouldn’t you? Please be clearer.

  • Give an example of some value that fails and another that must pass.

  • Must fail, any string "Hello world", "Approved registration", pass: "22/02/2017" Any date Me returns this ;Delimiter must not be alphanumeric or backslash in C: wamp www ecoprintQ ecoLicenseLayout json dados-partners-repots.php on line <i>14

  • Failed to put the delimiters in regex, leave so: preg_match( "#\d{1,2}/\d{1,2}/\d{4}$#"

  • Basically it’s a syntax error in Regex, I updated the tags.

1 answer

3


The delimiters are missing, the functions preg demand this and perhaps also lack the ^ in regex \d{1,2}/\d{1,2}/\d{4}$, do 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 delimiters are and how they work on PCRE: http://php.net/manual/en/regexp.reference.delimiters.php

  • Warning: preg_match(): No ending delimiter '#' found in

  • 1

    well, thanks, it worked out

  • @gabrielfalieri blz, that good!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.