matches the ABCD in <H1>ABCD</H1>?<H1>(<[A-Za-z0-9]+>)
I think not. Remove the < and >, and add an H1 closing tag to clarify, ie:
<H1>([A-Za-z0-9]+)</H1>
Or if you don't mind it picking up underscores as well as letters and numbers, you can use the much more succint:
\w means match a word character. I suggest you do a little search on parsing html in the Super Search, or look at the HTML::Parser module, discussed here<H1>(\w+)</H1>
You may want to also add modifiers to your regex, ie:
the i makes it case insensitive (picks up h1 and H1), the s make the regex treat the whole string/page as one line, matching H1's created by that lovely editor, Dreamweaver, eg:if ( m!$catreg!is ) {
<h1>I am a heading created by Dreamweaver</h1>
<rant>
(not that Dreamweaver users ever seem to use <Hn> when <p><b><font size=6> will do instead :)
</rant>
cLive ;-)
Update: I missed that you were matching a possible tag before the match you use (see below). I strongly suggest you look at a parsing module if you don't know whether tags will contain tags or not!
In reply to Re: (**corrected**) What Does This Line Do?
by cLive ;-)
in thread (**corrected**) What Does This Line Do?
by sfrattura
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |