例如:
从这个地址,我需要提取以下内容:
我已经尝试使用以下正则表达式:
(?<namespace>.*)/.*?
但是返回值是
http:
有人可以帮忙吗?谢谢。
最佳答案
试试这个:
^(?<namespace>.*)/[^/]+$
快速解释:
^ # the start of input
(?<namespace>.*)/ # zero or more chars followed by a '/' (which the last '/')
[^/]+ # one or more chars other than '/'
$ # the end of input
关于regex - 正则表达式 : Matching text up to last index of character,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7262547/