从 BBCode 检索 url,丢弃其他所有内容
我希望从 BBCode 块中删除除 Flickr 照片页面 URL 之外的所有内容,使用以下示例:
[url=http://www.flickr.com/photos/vrfan/6821895917/][img]http://farm8.staticflickr.com/7025/6821895917_a372a271a2_z.jpg[/img][/url]
[url=http://www.flickr.com/photos/vrfan/6821895917/]Y159 being sanded at Daylesford[/url] by [url=http://www.flickr.com/people/vrfan/]VRfan[/url], on Flickr
我想要的只是第一个 [url]
标记 ( http://www.flickr.com/photos/vrfan/6821895917/)
- 其他所有内容都可以删除。
希望正则表达式向导可以帮助我解决这个问题:)
干杯,
迈克尔。
I'm looking to strip all but the Flickr photo page URL from a block of BBCode, using the following as an example:
[url=http://www.flickr.com/photos/vrfan/6821895917/][img]http://farm8.staticflickr.com/7025/6821895917_a372a271a2_z.jpg[/img][/url]
[url=http://www.flickr.com/photos/vrfan/6821895917/]Y159 being sanded at Daylesford[/url] by [url=http://www.flickr.com/people/vrfan/]VRfan[/url], on Flickr
All I want is the value of the first [url]
tag (http://www.flickr.com/photos/vrfan/6821895917/)
- everything else can be removed.
Hopefully a regex wizard can help me out on this :)
Cheers,
Michael.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您也可以将
substr()
与strpos()
结合使用,而不是正则表达式。You can use
substr()
too combined withstrpos()
instead of Regex.