I am new to angular js . I have regex
which gets all the anchor tags
. My reg ex is
/]*>([^<]+)<\\/a>/g
Given the use case of parsing a string, instead of having an actual DOM to work with, it does seem like regex is the way to go, unless you want to load the HTML into a document fragment
and parse that.
One way to get all of your matches is to make use of split
:
var htmlstr = ""
var matches = htmlstr.split(/([A-Za-z.@]+)<\/a>/).filter((t, i) => i % 2)
Using a regex with split returns all of the matches along with the text around them, then filtering by index % 2 will pare it down to just the regex matches.