Is there a name for this address?
$u1="http://share.feedsportal.com/share/gplus/?u=http%3A%2F%2Fwww.cnbeta.com%2Farticles%2F244192.htm&t=%5B%E5%9B%BE%5D1366+x+768%E5%88%86%E8%BE%A8%E7%8E%87%2B%E8%A7%A6%E6%8E%A7+%E8%81%94%E6%83%B3ThinkPad+X240s%E8%B6%85%E6%9E%81%E6%9C%AC%E6%9B%9D%E5%85%89";$u2="http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn%2Fattachement%2Fjpg%2Fsite1%2F20131008%2F001e90ad746b13bdae620a.jpg&fm=30
How to use regular expressions to propose real addresses
$ U1 = http://www.cnbeta.com/articles/244192.htm
$ U2 = http://auto.shm.com.cn/attachement/jpg/site1/20131008/001e90ad746b13bdae620a.jpg
Reply to discussion (solution)
Convert it into an array without regular expression, and then combine it by yourself.
$u1="http://share.feedsportal.com/share/gplus/?u=http%3A%2F%2Fwww.cnbeta.com%2Farticles%2F244192.htm&t=%5B%E5%9B%BE%5D1366+x+768%E5%88%86%E8%BE%A8%E7%8E%87%2B%E8%A7%A6%E6%8E%A7+%E8%81%94%E6%83%B3ThinkPad+X240s%E8%B6%85%E6%9E%81%E6%9C%AC%E6%9B%9D%E5%85%89";$c1 = parse_url($u1, PHP_URL_QUERY);parse_str($c1, $params);echo $params['u'];
$u1="http://share.feedsportal.com/share/gplus/?u=http%3A%2F%2Fwww.cnbeta.com%2Farticles%2F244192.htm&t=%5B%E5%9B%BE%5D1366+x+768%E5%88%86%E8%BE%A8%E7%8E%87%2B%E8%A7%A6%E6%8E%A7+%E8%81%94%E6%83%B3ThinkPad+X240s%E8%B6%85%E6%9E%81%E6%9C%AC%E6%9B%9D%E5%85%89";$c1 = parse_url($u1, PHP_URL_QUERY);parse_str($c1, $params);echo $params['u'];
What I need is regular expression extraction.
Why? the 2 # method is actually very good and efficient.
$u1="http://share.feedsportal.com/share/gplus/?u=http%3A%2F%2Fwww.cnbeta.com%2Farticles%2F244192.htm&t=%5B%E5%9B%BE%5D1366+x+768%E5%88%86%E8%BE%A8%E7%8E%87%2B%E8%A7%A6%E6%8E%A7+%E8%81%94%E6%83%B3ThinkPad+X240s%E8%B6%85%E6%9E%81%E6%9C%AC%E6%9B%9D%E5%85%89";$u2="http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn%2Fattachement%2Fjpg%2Fsite1%2F20131008%2F001e90ad746b13bdae620a.jpg&fm=30";preg_match('/u=([^&]+)&/',$u1,$m1);preg_match('/u=([^&]+)&/',$u2,$m2);echo urldecode($m1[1]);echo "
";echo urldecode($m2[1]);
$u1 = "http://share.feedsportal.com/share/gplus/?u=http%3A%2F%2Fwww.cnbeta.com%2Farticles%2F244192.htm&t=%5B%E5%9B%BE%5D1366+x+768%E5%88%86%E8%BE%A8%E7%8E%87%2B%E8%A7%A6%E6%8E%A7+%E8%81%94%E6%83%B3ThinkPad+X240s%E8%B6%85%E6%9E%81%E6%9C%AC%E6%9B%9D%E5%85%89";$u2 = "http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn%2Fattachement%2Fjpg%2Fsite1%2F20131008%2F001e90ad746b13bdae620a.jpg&fm=30";preg_match('/u=([^&]+)/', $u1, $r);echo urldecode($r[1]);preg_match('/u=([^&]+)/', $u2, $r);echo urldecode($r[1]);
Http://www.cnbeta.com/articles/244192.htm
Http://auto.shm.com.cn/attachement/jpg/site1/20131008/001e90ad746b13bdae620a.jpg
$u1 = "http://share.feedsportal.com/share/gplus/?u=http%3A%2F%2Fwww.cnbeta.com%2Farticles%2F244192.htm&t=%5B%E5%9B%BE%5D1366+x+768%E5%88%86%E8%BE%A8%E7%8E%87%2B%E8%A7%A6%E6%8E%A7+%E8%81%94%E6%83%B3ThinkPad+X240s%E8%B6%85%E6%9E%81%E6%9C%AC%E6%9B%9D%E5%85%89";$u2 = "http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn%2Fattachement%2Fjpg%2Fsite1%2F20131008%2F001e90ad746b13bdae620a.jpg&fm=30";preg_match('/u=([^&]+)/', $u1, $r);echo urldecode($r[1]);preg_match('/u=([^&]+)/', $u2, $r);echo urldecode($r[1]);
Http://www.cnbeta.com/articles/244192.htm
Http://auto.shm.com.cn/attachement/jpg/site1/20131008/001e90ad746b13bdae620a.jpg
If it is not u =, it cannot be used. can it be matched from the second http?
Why? the 2 # method is actually very good and efficient.
$u1="http://share.feedsportal.com/share/gplus/?u=http%3A%2F%2Fwww.cnbeta.com%2Farticles%2F244192.htm&t=%5B%E5%9B%BE%5D1366+x+768%E5%88%86%E8%BE%A8%E7%8E%87%2B%E8%A7%A6%E6%8E%A7+%E8%81%94%E6%83%B3ThinkPad+X240s%E8%B6%85%E6%9E%81%E6%9C%AC%E6%9B%9D%E5%85%89";$u2="http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn%2Fattachement%2Fjpg%2Fsite1%2F20131008%2F001e90ad746b13bdae620a.jpg&fm=30";preg_match('/u=([^&]+)&/',$u1,$m1);preg_match('/u=([^&]+)&/',$u2,$m2);echo urldecode($m1[1]);echo "
";echo urldecode($m2[1]);
My content contains strings that contain both Chinese and English characters or images.
For example:
Sina Leju News (reporter Li Xiaona) on September, Yantai property market supply and demand two prosperous, perfect ending. The current sales rankings have been released. the sales volume of commercial housing in area 6 of Yantai in September was RMB 2.588 billion, up 14.5% from the previous month. In the ranking list of the number of transactions in Zone 6 projects, 320 sets of transactions were made in the development zone of Huaming Star Bay (search for the map of the Forum photo album Model Room reviews), ranking first. Wanda won the deal with 0.263 billion yuan
Can you just remove the u?
Can you just remove the u?
Thank you for your reply.
Can you just remove the u?
public static function getRealUrl($url){$uri=$url;preg_match_all("/=([^&]+)&/", $url, $match);if(is_array($match[1]) && sizeof($match[1])>=1){$uri=$match[1][0];}return urldecode($uri);}
The above method is also called elsewhere, and the following is the output description
Public function coverDescriptionOut () {// 2013070302 global $ str; $ desc = $ str-> apoDecodeCharacter ($ this-> getDescription ()); // 2013100802 // The Image address preg_match_all ('// siu', $ desc, $ match); return (! Empty ($ match [1])? Str_replace ($ match [1] [0], haloURI: getRealUrl ($ match [1] [0]), $ desc): $ desc ;}
I would like to ask: how can I use the preg_replace_callback method to rewrite the coverDescriptionOut method above?