View Single Post
Old 05-16-2009, 09:12 PM   #11
maverickstruth
Backup Goalie
 
maverickstruth's Avatar
 
Join Date: Mar 2006
Location: Calgary
Exp:
Default

Try something like... this?

Code:
<([A-Z][A-Z0-9]*)\b[^>]*>(.*?)</\1>
(Got it from http://www.regular-expressions.info/examples.html, but basically all it's doing is finding a tag, then matching everything between that tag and it's closing tag using the \1 backreference)

Gah, just reread. You've got that part working already.

What about... (warning, this is really messy and probably won't work)

Code:
<([A-Z][A-Z0-9]*)(\b[^>]*)?(<!--(\b[^>]*)?>)?(\b[^>]*)?>
< to capture the beginning of the tag
([A-Z][A-Z0-9]*) to capture the tag itself (note, you may need to include lower case here)
(\b[^>]*)? to capture anything that does not include a >
(<!--(\b[^>]*)?>)? to capture zero or more words after <!-- but before >, which may never occur
(\b[^>]*)? to capture zero or more words after the html comment
> to capture the end of the tag

Last edited by maverickstruth; 05-16-2009 at 09:40 PM. Reason: correcting myself, hopefully
maverickstruth is offline   Reply With Quote