普通的前pression匹配&LT; A HREF =&QUOT;邮寄地址: [英] Regular expression to match <a href="mailto:
本文介绍了普通的前pression匹配&LT; A HREF =&QUOT;邮寄地址:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想匹配所有
<a href="mailto:abc@abc.com">bla bla bla</a>
和我还有一个过滤器,将追加
and I have another filter that will append
<a rel="email" href="mailto:abc@abc.com">bla bla bla</a>
所以,我在找正规前pression会发现,与替换功能。
So I am looking for the regular expression that will find that with the replace function.
推荐答案
请使用HTML解析器来代替。您还没有指定的语言,但这里的使用Python中BeautifulSoup示范:
Please use an html parser instead. You haven't specified a language, but here's a demonstration using BeautifulSoup in Python:
>>> from BeautifulSoup import BeautifulSoup
>>> soup = BeautifulSoup('<a href="mailto:abc@abc.com">bla bla bla</a>')
>>> for a in soup.findAll('a'):
... a['rel'] = 'email'
...
>>> soup.prettify()
'<a href="mailto:abc@abc.com" rel="email">\n bla bla bla\n</a>'
这篇关于普通的前pression匹配&LT; A HREF =&QUOT;邮寄地址:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文