PHP Warning: preg_match()

Asked

Viewed 50 times

0

follows the code:

$ER = '[\/]?([?]?pag=[a-zA-Z0-9_-]*)(&var1=[a-zA-Z0-9_-]*)?(&var2=[a-zA-Z0-9_-]*)?(&var3=[a-zA-Z0-9_-]*)?(&var4=[a-zA-Z0-9_-]*)?'; // A ER que separa as vars
$wURL = W_URL;
$http = 'http://';
if( $https || $_SERVER["SERVER_PORT"] != 80 ){
    $url_site =  str_replace('http:', 'https:', URL_SITE);
}else{
    $url_site =  URL_SITE;
}
$_save_pag = '';
//Executa o rewrite somente quando estiver definido para tal
if($doRewrite == true){

    if(empty($str) && preg_match($ER,$str,$registers)){

error:

PHP Warning: preg_match(): Unknown Modifier '?' in /home/sisv2/sis_adm/includes/functions/rewrite.func.php on line 17

  • 1

    What is the regular expression?

  • $ER = '[/]? ([? ]? pag=[a-za-Z0-9_-])(&var1=[a-za-Z0-9_-])?(&var2=[a-za-Z0-9_-])?(&var3=[a-za-Z0-9_-])?(&var4=[a-za-Z0-9_-]*)?';

  • 1

    Supplement the question with regular expression.

  • ready put there

1 answer

0


This error is happening because its expression must be bounded by '/' or '#'.

Soon she’d be like this:

$ER = '/[\/]?([?]?pag=[a-zA-Z0-9_-]*)(&var1=[a-zA-Z0-9_-]*)?(&var2=[a-zA-Z0-9_-]*)?(&var3=[a-zA-Z0-9_-]*)?(&var4=[a-zA-Z0-9_-]*)?/'; // A ER que separa as vars

This happens because when you specify options for their regular expression (multi-line, single line, case sensitive etc.) they are "outside" of the expression, after the second delimiter.

Browser other questions tagged

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