[英]Regular expression to match <a href="mailto:
I am trying to match all 我想要匹配所有
<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>
So I am looking for the regular expression that will find that with the replace function. 所以我正在寻找使用replace函数找到的正则表达式。
Please use an html parser instead. 请改用html解析器。 You haven't specified a language, but here's a demonstration using BeautifulSoup in Python: 您尚未指定语言,但这是使用Python中的BeautifulSoup进行的演示:
>>> 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>'
你可以看看这里: http : //reflexxion.de/2010/11/e-mail-adresse-gueltig/
/^([a-zA-Z0-9\.\_\-]+)@([a-zA-Z0-9\.\-]+\.[A-Za-z]{2,4})$/
Look here: http://msdn.microsoft.com/en-us/library/ms972966.aspx#regexnet_topic13 .. so just do 看这里: http : //msdn.microsoft.com/en-us/library/ms972966.aspx#regexnet_topic13 ..所以只做
input = Regex.Replace(input, "<a href=\"mailto:(?<mailaddress>[^\"]*)\">(?<linktext>[^<]*)</a>", "<a rel=\"email\" href=\"mailto:${mailaddress}\">${linktext}</a>");
or something along these lines ... 或者沿着这些方向的东西......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.