The first rule of using a regex to parse HTML is don't do it.
The second rule of using a regex to parse HTML is PLEASE don't do it.
Below you'll find your regex in expanded form (it's a wonderful advancement in regexes, all whitespace is ignored and comments can be introduced), and commented. Maybe that will help you spot something.
I generally find it useful to reduce the regex to the bare minimum, send it against some test content, and keep adding back in stuff I think should work bit by bit until it breaks.
/
< # Begin tag
\/? # Optional slash denoting a closing element
\w+ # Tag name
( # MATCH 1
(\s+ # MATCH 2
\s+ # REQUIRED spaces
(\w|\w[\w-]*\w) # MATCH 3 (attribute), Single char or multiple chars with optional hyphen bordered by chars
( # MATCH 4, OPTIONAL
\s*=\s* # = with optional bordering spaces
(?: # Non-matching group
\".*?\" # Non-greedy match of double quoted string
|
'.*?' # Non-greedy match of single quoted string
|
[^'\">\s]+ # NOT single or double quote, right angle, or space 1+ times
)
)?
)+
\s*|\s*
)
\/? # Optional ending slash denoting self closing element
>
/xi
-- GandK Labs
Check out Reversi! in the channel store!