开发者

regex to get part of string from end

I have some URLs like

http://wac.0E23.ed2323sdf.net/800E13/www.myexample.gr/

http://wa开发者_运维技巧c.0E22.ed2323sdf.net/812E13/www.my1example.gr/

http://wac.0E23.ed2323sdf.net/802E13/www.my2example.gr/

I have to write regular expression to get the site name i.e www.myexample.gr, www.my1example.gr and www.my2example.gr

I wrote an expression to find the last occurrence of / but I am not able to capture the string between second last /.

Any idea how to achieve this?.

Regards,


It depends on what language you're using (perl? elisp?). Usually, that would be extracted by the following:

"/([^/]+)/$"

where I put the regex between ". I do that because most languages use // as a search pattern definition in itself. And, depending on the language, the result would be in the first parenthesis value (in some languages \1, in others $1, in others (match-string 1)...)


How about this expression:

~([^/]+)/$~
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜