Aaaagh! Simple RegExp Help Needed

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View


I write fairly complex regexps on a daily basis (complex to me anyway)
but I didn't get much sleep last night and I think that's why this one
is doing my nut. I can't for the life of me work out why:

my $test = "Lalalala <head>this is the \nhead zone\n\n<other
tag></other tag>\n\n<!--lalalala-->\n</head> totototot";
$test =~ s/<head>.*<\/head>//;

Doesn't strip out everything between and including the
<head>....</head> HTML tags.

I know it's not the most robust regexp. It's a simplified form of what
I actually want, but it best illustrates my point.

I'm missing something obvious I know... but what?



Re: Aaaagh! Simple RegExp Help Needed wrote:
Quoted text here. Click to load it

You are missing that your string contains multiple lines and . doesn't match
a newline unless you specify the s modifier.


Re: Aaaagh! Simple RegExp Help Needed


Thank you!

Site Timeline