Reputation: 255
I have a regex string: .*href="\/anime\/(\d*)\/.*class="animetitle".*<span>(.*)<\/span>.*[\s].*<span id="scoreval\d*">(\d*)<\/span>.*<\/td>[\s].*align="center">(.*)<\/td>
You can see this regex in regex101.
And when I put that in VBA, some error come.
regEx.Pattern = ".*href="\/anime\/(\d*)\/.*class="animetitle".*<span>(.*)<\/span>.*[\s].*<span id="scoreval\d*">(\d*)<\/span>.*<\/td>[\s].*align="center">(.*)<\/td>"
.*href="\
/
anime
Is the first error, but I can't understand that. Maybe some "
are the problem. But what about the \
who is normally escape that character.
Upvotes: 1
Views: 2389
Reputation: 4649
I believe in VBA you have to escape the string-delimiter ("
) by doubling it. So:
regEx.Pattern = ".*href=""\/anime\/(\d*)\/.*class=""animetitle"".*<span>(.*)<\/span>.*[\s].*<span id=""scoreval\d*"">(\d*)<\/span>.*<\/td>[\s].*align=""center"">(.*)<\/td>"
As a side note, I would discourage you from using regexes to parse HTML. This website explains why and offers alternatives in some languages. If there's a HTML-parser for VBA, I would encourage you to use that in stead :)
Upvotes: 3