提取URI上的最后一段 [英] Extracting the last segment on an URI
本文介绍了提取URI上的最后一段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
字符串#1:
/string/morestring/thename
字符串#2:
/string/morestring/thename/
正则表达式:
[^\/]*[\/]*$
上面的正则表达式匹配最后两个段...
The above regex matches both last segments...
正则表达式如何仅在"thename"和"thename/"上仅匹配最后一个单词(带有或不带有最后斜杠)?
How can the regex match only the last word on both "thename" AND "thename/", with or without final slash?
推荐答案
[^\/]+\/?$
http://rubular.com/r/TeAEWM0jsd
这篇关于提取URI上的最后一段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文