Home >Backend Development >PHP Tutorial >麻烦帮我看看这个该怎么正则匹配

麻烦帮我看看这个该怎么正则匹配

WBOY
WBOYOriginal
2016-06-23 13:10:48773browse

1.
http://abc/innd/ffdss/Jack
2.
http://abc/innd/ffdss/dfdf/ssss/Peter
3.
http://abc/ffdss/Sam

麻烦大神用一句正则匹配末尾把这三个网址最后的Jack、Peter和Sam匹配出来

好久不用正则忘记了- -


回复讨论(解决方案)

//可以不需要正则$url = 'http://abc/innd/ffdss/Jack';echo substr($url, strrpos($url, '/')+1);

//可以不需要正则$url = 'http://abc/innd/ffdss/Jack';echo substr($url, strrpos($url, '/')+1);



谢谢不过我们老师说要用正则,能不能教一下正则该怎么做

$s = 'http://abc/innd/ffdss/Jack';preg_match('#/([^/]+)$#', $s, $m);echo $m[1];

Statement:
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
Previous article:php读取zip注释Next article:php模板取值