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.
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>'
你可以看看这里: 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
input = Regex.Replace(input, "<a href=\"mailto:(?<mailaddress>[^\"]*)\">(?<linktext>[^<]*)</a>", "<a rel=\"email\" href=\"mailto:${mailaddress}\">${linktext}</a>");
or something along these lines ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.