I want to get regex for the following construct where it should result as:
Actions and Sci-Fi
<a href="/?genre=Action">Actions</a> <a href="/?genre=Sci-Fi">Sci-Fi</a>
Don't parse html files with regex. If you insist then you could use the below regex and get the text inside anchor tags from group index 1.
<a\s[^<>]*>([^<>]*)<\/a>
Explanation:
<a '<a'
\s whitespace (\n, \r, \t, \f, and " ")
[^<>]* any character except: '<', '>' (0 or more
times)
> '>'
( group and capture to \1:
[^<>]* any character except: '<', '>' (0 or
more times)
) end of \1
< '<'
\/ '/'
a> 'a>'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句