Jump to content

a problem with preg_match


catzilla

Recommended Posts

why $output[2] = "yahoo-inc.c" instead of "yahoo-inc.com" ? thanks for answer in advance

<?php

$mail = "cc.yahoo-inc.com";
preg_match('/(\w+\.*\w+\.)([\w|\-]+\.[aero|biz|cat|com|coop|info|jobs|mobi|museum|name|net|org|pro|travel|gov|edu|int])/i',$mail,$output);
print_r($output);

?>

# php tr7.php
Array
(
[0] => cc.yahoo-inc.c
[1] => cc.
[2] => yahoo-inc.c
)
Link to comment
https://forums.phpfreaks.com/topic/10842-a-problem-with-preg_match/
Share on other sites

[code]<?php

$mail = "cc.yahoo-inc.com";
preg_match('/(\w+\.*\w+\.)([\w|\-]+\.(aero|biz|cat|com|coop|info|jobs|mobi|museum|name|net|org|pro|travel|gov|edu|int))/i',$mail,$output);

print_r($output);

?>[/code]

Should output:

[code]Array
(
    [0] => cc.yahoo-inc.com
    [1] => cc.
    [2] => yahoo-inc.com
    [3] => com
)[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.