PHP string Manipulation related issues

Source: Internet
Author: User
PHP String Manipulation issues
String: {user:link islocal= ' 1 '}/2013/userup/100/131a2z34-5n8.doc {/user:link}
How to remove 131a2z34-5n8 string???
For example, there are many similar strings:
String 1:{user:link islocal= ' 1 '}/2013/userup/100/131a2z34-800.doc {/user:link}
String 2:{user:link islocal= ' 1 '}/2013/userup/100/131a2z34-801.doc {/user:link}
String 3:{user:link islocal= ' 1 '}/2013/userup/100/131a2z34-802.doc {/user:link}
Remove the string separately:
131a2z34-800
131a2z34-801
131a2z34-802

Do you want to use regular, how to do it?

Share to:


------Solution--------------------
$s =<<
 <>
String 1:{user:link islocal= ' 1 '}/2013/userup/100/131a2z34-800.doc {/user:link}
String 2:{user:link islocal= ' 1 '}/2013/userup/100/131a2z34-801.doc {/user:link}
String 3:{user:link islocal= ' 1 '}/2013/userup/100/131a2z34-802.doc {/user:link}
txt
Preg_match_all (' #/([^/]+) \.doc\s*{/user#su ', $s, $m);
Print_r ($m [1]);

------Solution--------------------
Preg_match_all (' #/([^/]+?) \.# ', $s, $m);
Print_r ($m [1]);
  • 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.