需要帮助才能获得正则表达式 [英] need help to get regex pattern
本文介绍了需要帮助才能获得正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从以下html代码中提取一些值。
Hi, I want to extract some value from the following html code.
<a class="listing-name" title="view more about this business"
href="/nsw/sydney/paul-paul-laywers-12345678-
listing.html?referredby =www.yellowpages.com.au&
context=businesstypesearch"></a>
我想得到一个价值paul-paul来自上面的HTML代码的律师。
我尝试使用Expresso自己。但我无法达到结果。
拜托,建议我正确的正则表达式模式。
谢谢。
I want to get a value paul-paul-lawyers from the above html code.
I tried my self using Expresso. but I could not achieve the result.
please, suggest me correct regex pattern for this.
Thanks.
推荐答案
试试:
Try:
(?<=href=")(?:\w*/)*(.*)(?:-[^-]*)(?:-[^-]*)(?=\.html)
试试这个:
Try this:
(?<=/)[a-zA-Z\-]+(?=\-\d)
这将匹配任何' - '分隔的字母以'/'开头并以'结尾' - '和数字但不包括在内。
This will match any '-' delimited alphabets starts with '/' and end with a '-' and number but both not inclusive.
这篇关于需要帮助才能获得正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文