Starting out inreg expressions..

X-No-Archive: yes

I'm starting out in Regular Expressions and need help with something, how do
I say:

(This is just a banner ad and I want to search for the tag in any files:)

<!-- TAG BANNER START -->

anything between here as it can be a different banner code but the two tags
above are always present.

<!-- TAG BANNER END -->

Example, the banner code changes:

<!-- TAG BANNER START -->
<script language="javascript">
var uri = 'http://xxxx.xxxxxx.xxx/imp/js/848986/404265?' + new String
(Math.random()).substring (2, 11);
document.write('<sc'+'ript language="JavaScript" src="'+uri+'"
charset="ISO-8859-1"></sc'+'ript>');
</script>
<!-- TAG BANNER END -->

As a Reg. Exp ?
127.0.0.1 [ Mo, 29 November 2004 05:00 ] [ ID #507574 ]

Re: Starting out inreg expressions..

127.0.0.1 wrote:

> I'm starting out in Regular Expressions and need help with something, how do
> I say:
>
> <!-- TAG BANNER START -->
>
> anything between here as it can be a different banner code but the two tags
> above are always present.
>
> <!-- TAG BANNER END -->

Assuming Perl-compatible regular expressions, personally I'd match on:

/<!-- TAG BANNER START -->.*?<!-- TAG BANNER END -->/s

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Toby Inkster [ Mo, 29 November 2004 08:31 ] [ ID #507885 ]
Perl » alt.perl » Starting out inreg expressions..

Vorheriges Thema: The Perl Review, Winter 2004
Nächstes Thema: Perl call unix shell script