Use a regular expression to extract URLPHP from a paragraph of text use a regular expression to extract a URL from a paragraph of text. the existing section of text is like "c. do you know how to extract comdkae?" I want to extract it to c. comdkaeaa. please give me some ideas ------ solution -------------------- PHPcode $ str what do pig eat? what do I need so fat http use regular expressions to extract URLs from a paragraph of text
PHP uses regular expressions to extract URLs from a paragraph of text
There is a piece of text like "what do pig eat ?"
I want to extract to http://c.com/dkaeaa
Please give me some ideas
------ Solution --------------------
PHP code
$ Str = 'What is the pig eating? do I need to extract this fat content from http://c.com/dkae? '; Preg_match_all ('/https? : \/[\ W-. % #? \/\] +/I ', $ str, $ matches); print_r ($ matches);/** output result: array ([0] => Array ([0] => http://c.com/dkae ))*/