开发者

A simple regex, extract what is between "/d/" and "/"

I need to extract the xxxx in the following string in a url:

{anything}/d/xxxx/{anything}

That is, get whatever is between "/d/" and the first "/" after that, and forg开发者_高级运维et the rest.


You haven't noticed what language you are using.

.+\/d\/([^\/]+).+

will do it and have the searched part in $1 (in perl)


/d/(.*?)/

Will give you a capture group containing what you want.

Regular Expression Tutorial is a decent place to start, otherwise get a tool such as Expresso and have a play around! It'll give you a plain text interpretation of the what your regular expression means.

Here's a tutorial to go along with Expresso: The 30 Minute Regex Tutorial.


As for the question - I'm not really sure, but I've got this site bookmarked. It's a pretty good Tutorial.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜