preg_match_all 查询以获取 imdb 页面中的流派
preg_match_all("/\(.*?)\/",$this->page["标题"],$matches);
伙计们,$this->page["Title"] 是像 http:// 这样的页面的内容uk.imdb.com/title/tt1285016/。我需要获取与电影相关的类型列表,即 [动作 | 动作]戏剧 |科幻]
我不知道任何 php 或任何有关正则表达式的内容。我一直讨厌模式匹配
这里的帮助将非常感激。谢谢。
要点:这是我需要修改的现有代码。这是在 php 中。
preg_match_all("/\(.*?)\</a>/",$this->page["Title"],$matches);
Guys, $this->page["Title"] is the contents of a page like http://uk.imdb.com/title/tt1285016/ . I need to get the list of genres associated with the movies i.e. [Action | Drama | Sci-Fi]
I dont know any php or anything about regular expressions. I always hated pattern matching
Help here will be really appreciated. Thx.
Point : This is an existing code which I need to Modify. This is in php.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这应该效果更好:
This should work better:
试试这个
Try this
您应该尝试使用众多 PHP HTML 解析器之一。
特别是,您应该查看 PHP 本机 DOMDocument 文档。
Finally - as I posted in the comment above - parsing HTML with regular expressions is a touchy subject - follow the link to learn more :)
RegEx 匹配开放标记(XHTML 自包含标记除外)
You should try using one of the many PHP HTML parsers.
In particular you should look at the PHP native DOMDocument documentation.
Finally - as I posted in the comment above - parsing HTML with regular expressions is a touchy subject - follow the link to learn more :)
RegEx match open tags except XHTML self-contained tags