0

Possible Duplicate:
Warning: preg_match() [function.preg-match]: Unknown modifier '/'

I am having troubles with this code wich gives me the next error:

Warning: preg_match() [function.preg-match]: Unknown modifier '{' in /usr/home/anubis-cosmetics.com/web/includes/functions/functions_email.php on line 568

Warning: preg_match() [function.preg-match]: No ending delimiter '^' found in /usr/home/anubis-cosmetics.com/web/includes/functions/functions_email.php on line 586

Line 568:

 if email domain part is an IP address, check each part for a value under 256
    if (!preg_match ($valid_ip_form, $domain)) {
      $digit = explode( ".", $domain );
      for($i=0; $i<4; $i++) {
        if ($digit[$i] > 255) {
          $valid_address = false;
          return $valid_address;
          exit;
        }

Line 586:

if (!preg_match($space_check, $email)) { // trap for spaces in
      if (!preg_match ($valid_email_pattern, $email)) { // validate against valid email patterns
        $valid_address = true;
      } else {
        $valid_address = false;
        return $valid_address;
        exit;
      }
    }
    return $valid_address;
  }


?>

I don't know how to do it, can someone help me with this?

EDIT/////

I've tried to change the delimiters for this: # --->

// if email domain part is an IP address, check each part for a value under 256
    if (!preg_match ($valid_ip_form, $domain))#
      $digit = explode( ".", $domain );

And the other one for this:

if (!preg_match($space_check, $email)) { // trap for spaces in
      if (!preg_match ($valid_email_pattern, $email)) { // validate against valid email patterns
        $valid_address = true;
      } else {
        $valid_address = false;
        return $valid_address;
        exit;
      }
    }
    return $valid_address;#

And still without work... Can someone be more especific (showing me some example inline) about the problem? Thanks!

Community
  • 1
  • 1
Xavi Alsina
  • 643
  • 1
  • 8
  • 24

1 Answers1

2

The problem is with your $valid_ip_form respectively $space_check. They will be invalid php PCRE expressions.

I guess you're missing opening and closing delimiters and your expression looks like:

^[0-9]{3}$

Instead of:

~^[0-9]{3}$~
/^[0-9]{3}$/
#^[0-9]{3}$#

or whatever else you like.

Post them if you want more info

Vyktor
  • 20,559
  • 6
  • 64
  • 96
  • Just to make sure: I don't think the delimiters are part of an PCRE (or are they?). I think PHP requires them to denote a regular expression, but they are not part of the actual expression. So, `$valid_ip_form` might be a valid expression, but not something PHP can work with. – Felix Kling Oct 09 '12 at 07:37
  • @FelixKling as I understand it... PHP calls it P**C**RE due to some changes they made to them (e.g. adding delimiters)... If you have any source that says otherwise I'd be glad to learn something new and modify my answer. – Vyktor Oct 09 '12 at 07:39
  • PCRE is actually a standalone library and simply used/implemented by PHP. See http://www.pcre.org/pcre.txt. Fun fact: The term `delimiter` only occurs once in the whole document ;) But I did not read it, so that's why I was asking. – Felix Kling Oct 09 '12 at 07:41
  • What do you mean with the problem of $valid_ip_form ?? Well, i'm lost guys about it, and Vyktor, where should be exactly the delimiters? I mean I am not a PHP programmer, so i'm just trying to actualize de PHP4 to PHP5. Thanks – Xavi Alsina Oct 09 '12 at 07:43
  • @FelixKling you're right, I've changed it to `php PCRE`, this should be correct :) – Vyktor Oct 09 '12 at 07:43
  • @user1730884 that you DO have incorrect invalid regular expression in that variable. – Vyktor Oct 09 '12 at 07:44
  • Yeah... I guess one could actually deduce this from the documentation: *"When using the PCRE functions, it is required that the pattern is enclosed by delimiters."*. So the delimiters are not part of the pattern. I know this is a lot of nitpick, but I see people coming from PHP (but not only) using delimiters everywhere else as part of the expression and wondering why things don't work out. That's why it is important IMO to point out that these are separate things. Anyways, have a good day :) – Felix Kling Oct 09 '12 at 07:46
  • @user1730884: Have a look at the link... it has examples and this answer has examples too. – Felix Kling Oct 09 '12 at 07:47
  • @Vyktor could you explain it to me with an example? Thanks – Xavi Alsina Oct 09 '12 at 07:49