Ken Bloom
11/15/2006 8:34:00 PM
Ajay Vijey wrote:
> Hugh Sasse wrote:
> > I'd agree with your choice of regexp. I think we need to see more of
> > the surrounding code to fix this.
>
>
> rubyscript
> --------------
> datei_new = IO.read("index.htm")
> datei_regexp = datei_new.scan(/(<img.*>)/m)
>
> puts datei_regexp
>
>
>
> index.htm
> ------------
>
> <html>
> <head><title>test</title></head>
> <body>
> <table>
> <tr>
> <td bordercolor="#FFFFFF">
>
> <table border="0" id="table2" bgcolor="#FFFFFF" width="100%">
> <tr>
>
> <td align="left" valign="top" width="25%"><a href="../personal/po.htm">
> <img src="images/animationpundo_schwarz_kl.gif"
> alt="Personal und Organisation" border="0" width="84"
> height="64"></a></td>
>
> <td align="left" valign="top" width="25%"><font face="Arial"><a
> href="../personal/po.htm"></font></td>
>
> </tr>
> </table>
>
> </td>
> </tr>
> </table>
> </body>
> </html>
Works for me with datei_new.scan(/(<img.*?>)/m) (the .*? performs a
non-greedy match so it stops with the smallest match it can make,
rather than the longest)
The parentheses you have around the text of the regexp are unnecessary,
they cause the results to be more deeply nested in arrays. You should
use /<img.*?>/m
--Ken Bloom