Forum Moderators: coopster

Message Too Old, No Replies

regex: get <h1> tag content

also if <h1> contains style or align parameters

         

ikbenhet1

5:55 pm on Jun 7, 2003 (gmt 0)

10+ Year Member



How can i get the content between h1 in a string when it contains 1 or more parameters/variables?

<h1> content </h1>
<h1 align=center> content </h1>
<h1 align="center" style=""> content </h1>

I would like to apply it like this:
if (eregi("<h1>(.*)</h1>", $data, $out)) {
$h_1=$out[1];
}

while searching, i found the answer on another forum , but their code gives a REG_BADRPT error message.
their code: /<h1(\d*)[^>]*>.*?<\/h\1\s*>/is

ikbenhet1

7:24 pm on Jun 7, 2003 (gmt 0)

10+ Year Member




This would be the correct code:

if (preg_match_all("=<h1[^>]*>(.*)</h1>=siU", $out, $data)) {
$h_1=$out[1];
}

finally found it.