For one thing, this:
[Green|Red]
doesn't do what you think it does. You want:
(?:Green|Red)
[Green|Red]
is a character class made up of the letters GRred|
, not a way of alternating between matches. The way you've written it, it will match exactly one of those characters followed by any number of other characters.
This:
[\s]
is redundant and maybe hazardous (depending on interpretation it could be what's actually making your match not work). It can be just
\s
In order for your second \s
to work, the capturing expression probably needs to be
(.*?)
I also recommend making your first .*
into [^>]*
, to avoid the problem you'll get if you ever apply this to actual HTML documents, where it will suck in arbitrary amounts of HTML.