[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Regexps and HTML comments

Jari Williamsson

11/22/2007 7:26:00 PM

I have troubles with the regexp to get HTML comments ("<!-- some text
-->") from a long (multi-line) string. Comments that have line breaks
aren't found, only the comments that are on the same line.

Here's my current code:
result = s.match(/\<!--(.*?)--\>)

How do I get the regexp to scan for the pattern beyond newlines?


Best regards,

Jari Willimasson

1 Answer

Greg Willits

11/22/2007 7:40:00 PM

0

Jari Williamsson wrote:
> I have troubles with the regexp to get HTML comments ("<!-- some text
> -->") from a long (multi-line) string. Comments that have line breaks
> aren't found, only the comments that are on the same line.
>
> Here's my current code:
> result = s.match(/\<!--(.*?)--\>)
>
> How do I get the regexp to scan for the pattern beyond newlines?


Try this one:
result = s.match(/\<!--([\s\S]*?)--\>/)

-- gw

--
Posted via http://www.ruby-....