简体   繁体   中英

URL parsing in PHP

Do any PHP parsers exist that get all urls out of a string? I'd like an alternative to regex for getting all urls out of a string.

Update:

    $urls = "http://stackoverflow.com/question
             http://stackoverflow.com/questions";

    //no space between urls
    $urls = "http://stackoverflow.com/questionshttp://stackoverflow.com/questiond";

There is no very-easy alternative to regex. But It has been solved using regex already, see Extract URLs from text in PHP and PHP validation/regex for URL .

Regex is quite useful though. Perl and Javascript and Java, etc etc

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM