-1
$email_address_pattern="([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~]+\\.)+[a-zA-Z]{2,6}";
$address= "abc@gmail.com";
$length=strlen($address);

for($position=0;$position<$length;) {
    $match=preg_split($email_address_pattern,strtolower(substr($address,$position)),2);
    print_r($match);

    if(count($match)<2)
        break;

    $position+=strlen($match[0]);
    $next_position=$length-strlen($match[1]);
    $found=substr($address,$position,$next_position-$position);

    if(!strcmp($found,""))
        break;
    if(IsSet($addresses[$found]))
        $addresses[$found]++;
    else {
        $addresses[$found]=1;
        $position=$next_position;
    }
}

I get warning:

Warning: preg_split(): Unknown modifier '+' in /home/www/html/cusidevelopment/test.php on line 10

How can i solve it?

Thanks in advance

MrCode
  • 63,975
  • 10
  • 90
  • 112

2 Answers2

0

You have to add start and end symbols. Adding ü gives a working regex. (Also this site interprets your backticks as formatting so you need to backslash-escape those in your question.)

Try this:

$email_address_pattern="ü([-!#\$%&'*+./0-9=?A-Z^_`a-z{|}~])+@([-!#\$%&'*+/0-9=?A-Z^_`a-z{|}~]+\.)+[a-zA-Z]{2,6}ü";

And as you of course know, regex is not a good match for describing email addresses.

tomsv
  • 7,207
  • 6
  • 55
  • 88
0

Try this

$email_address_pattern="/([-!#\$%&'*+.\/0-9=?A-Z^_`a-z\{|\}~]+)@([-!#\$%&'*+\/0-9=?A-Z^_`a-z\{|\}~]+).[a-zA-Z]{2,6}/";
sourcecode
  • 1,802
  • 2
  • 15
  • 17