What's the name of this address?

Source: Internet
Author: User
$u 1= "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 "; $u 2=" http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn% 2fattachement%2fjpg%2fsite1%2f20131008%2f001e90ad746b13bdae620a.jpg&fm=30


How to make a real address with a regular
$u 1=http://www.cnbeta.com/articles/244192.htm
$u 2=http://auto.shm.com.cn/attachement/jpg/site1/20131008/001e90ad746b13bdae620a.jpg


Reply to discussion (solution)

Do not use regular, as an array, and then assemble yourself.

$u 1= "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 "; $c 1 = Parse_url ($u 1, php_url_query);p arse_str ($c 1, $params); Echo $params [' U '];

$u 1= "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 "; $c 1 = Parse_url ($u 1, php_url_query);p arse_str ($c 1, $params); Echo $params [' U '];


What I need is a regular extraction.

Why, the method is actually very good, very efficient.

$u 1= "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 "; $u 2=" http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn% 2fattachement%2fjpg%2fsite1%2f20131008%2f001e90ad746b13bdae620a.jpg&fm=30 ";p reg_match ('/u= ([^&]+) & /', $u 1, $m 1);p reg_match ('/u= ([^&]+) &/', $u 2, $m 2); Echo UrlDecode ($m 1[1]); echo "
"; Echo UrlDecode ($m 2[1]);

$u 1 = "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 "; $u 2 =" http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn% 2fattachement%2fjpg%2fsite1%2f20131008%2f001e90ad746b13bdae620a.jpg&fm=30 ";p reg_match ('/u= ([^&]+)/', $ U1, $r); Echo UrlDecode ($r [1]);p reg_match ('/u= ([^&]+)/', $u 2, $r); Echo UrlDecode ($r [1]);
Http://www.cnbeta.com/articles/244192.htm
Http://auto.shm.com.cn/attachement/jpg/site1/20131008/001e90ad746b13bdae620a.jpg

$u 1 = "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 "; $u 2 =" http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn% 2fattachement%2fjpg%2fsite1%2f20131008%2f001e90ad746b13bdae620a.jpg&fm=30 ";p reg_match ('/u= ([^&]+)/', $ U1, $r); Echo UrlDecode ($r [1]);p reg_match ('/u= ([^&]+)/', $u 2, $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's not u=, it's not going to make it, can you start with a second HTTP match

Why, the method is actually very good, very efficient.

$u 1= "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 "; $u 2=" http://t1.baidu.com/it/u=http%3A%2F%2Fauto.shm.com.cn% 2fattachement%2fjpg%2fsite1%2f20131008%2f001e90ad746b13bdae620a.jpg&fm=30 ";p reg_match ('/u= ([^&]+) & /', $u 1, $m 1);p reg_match ('/u= ([^&]+) &/', $u 2, $m 2); Echo UrlDecode ($m 1[1]); echo "
"; Echo UrlDecode ($m 2[1]);

My content has a mix of Chinese and English or add pictures of the string, not the light has the above URL
For example:
Sina Le Ju (reporter Li Xiaona) Gold September, Yantai property market supply and demand two prosperous, perfect ending. The current sales list has been released, Grams and Rui data shows that in September, Yantai Six district commercial housing transaction total amount of 2.588 billion yuan, the chain Rose 14.5%. Six district project deal number of the list, development zone, China Star Bay (Forum album type model room reviews map search) sold 320 sets, yours faithfully first. Wanda takes 263 million of the deal amount to win

So you're going to get rid of the U?

So you're going to get rid of the U?
Thank you for your reply.

So you're going to get rid of the U?

public static function Getrealurl ($url) {$uri = $url;p reg_match_all ("/= ([^&]+) &/", $url, $match); if (Is_array ($ MATCH[1]) && sizeof ($match [1]) >=1) {$uri = $match [1][0];} Return UrlDecode ($uri);}


The above method also has a call elsewhere, and the following is the output description
Public Function Coverdescriptionout () {//2013070302global $str; $desc = $str->apodecodecharacter ($this GetDescription ());//2013100802//handles the picture address of the description Preg_match_all ('//siu ', $desc, $match); return (!empty ($match [1]))? str_ Replace ($match [1][0], Halouri::getrealurl ($match [1][0]), $DESC): $desc;}


Want to ask: The above Coverdescriptionout method how to use the Preg_replace_callback method to rewrite
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.