Jump to content

Archived

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

catzilla

a problem with preg_match

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
)

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.