Find a php regular expression replacement rule

Source: Internet
Author: User
Tags php regular expression
Find a php regular expression replacement rule/e/tags/index. php? Page = 23 & tagname = % B9 % D8 % D3 % DA % D3 % D1 % D2 % EA % D5 % E4 % B9 % F3 % B5 % C4 % B8 % F1 % D1 % D4 & line = 3 & tempid = 13

Replace this with preg_replace ()
/Tag-% B9 % D8 % D3 % DA % D3 % D1 % D2 % EA % D5 % E4 % B9 % F3 % B5 % C4 % B8 % F1 % D1 % D4/ 23/

When page = 0, replace it
/Tag-% B9 % D8 % D3 % DA % D3 % D1 % D2 % EA % D5 % E4 % B9 % F3 % B5 % C4 % B8 % F1 % D1 % D4/


Reply to discussion (solution)

$str="/e/tags/index.php?page=0&tagname=%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4&line=3&tempid=13";$s= preg_replace_callback(     '#.+?page=(\d+)&tagname=([^&]+)&.+#',     create_function(            '$matches',            'return "/tag-$matches[2]/". ($matches[1] ? $matches[1]."/" : "");'        ),$str);echo $s;

/Tag-% B9 % D8 % D3 % DA % D3 % D1 % D2 % EA % D5 % E4 % B9 % F3 % B5 % C4 % B8 % F1 % D1 % D4/

$str="/e/tags/index.php?page=0&tagname=%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4&line=3&tempid=13";$s= preg_replace_callback(     '#.+?page=(\d+)&tagname=([^&]+)&.+#',     create_function(            '$matches',            'return "/tag-$matches[2]/". ($matches[1] ? $matches[1]."/" : "");'        ),$str);echo $s;

/Tag-% B9 % D8 % D3 % DA % D3 % D1 % D2 % EA % D5 % E4 % B9 % F3 % B5 % C4 % B8 % F1 % D1 % D4/

Thank you very much for helping me solve the problem every time. thank you.
Take a look at this for me.
Http://bbs.csdn.net/topics/390575116

$str="/e/tags/index.php?page=0&tagname=%B9%D8%D3%DA%D3%D1%D2%EA%D5%E4%B9%F3%B5%C4%B8%F1%D1%D4&line=3&tempid=13";$s= preg_replace_callback(     '#.+?page=(\d+)&tagname=([^&]+)&.+#',     create_function(            '$matches',            'return "/tag-$matches[2]/". ($matches[1] ? $matches[1]."/" : "");'        ),$str);echo $s;

/Tag-% B9 % D8 % D3 % DA % D3 % D1 % D2 % EA % D5 % E4 % B9 % F3 % B5 % C4 % B8 % F1 % D1 % D4/

Please refer
 5Home page 12

Why cannot this paragraph be replaced?

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.