php字符串操作问题

WBOY
Release: 2016-06-23 14:27:24
Original
916 people have browsed it

字符串:{user:link islocal='1'} /2013/userup/100/131a2Z34-5N8.doc {/user:link}
如何取出131a2Z34-5N8字符串???
比如有很多类似的字符串:
字符串1:{user:link islocal='1'} /2013/userup/100/131a2Z34-800.doc {/user:link}
字符串2:{user:link islocal='1'} /2013/userup/100/131a2Z34-801.doc {/user:link}
字符串3:{user:link islocal='1'} /2013/userup/100/131a2Z34-802.doc {/user:link}
分别取出字符串:
131a2Z34-800
131a2Z34-801
131a2Z34-802

要用正则吗,如何实现?


回复讨论(解决方案)

$s=<<<txt字符串1:{user:link islocal='1'} /2013/userup/100/131a2Z34-800.doc {/user:link}字符串2:{user:link islocal='1'} /2013/userup/100/131a2Z34-801.doc {/user:link}字符串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]);
Copy after login

有这种情况:
{user:link islocal='1'} /我是随机字符串/我是随机字符串/我是随机字符串/我是随机字符串 {/user:link}
只有" {/user:link}"相同,后面不一定是doc,可能是.xls .txt 但一定有.
我想只能从/131a2Z34-802.doc {/user:link}又手,但想不出来

preg_match_all('#/([^/]+?)\.#',$s,$m);print_r($m[1]);
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template