CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
.+? probs...

 



AndyNewby
Novice

May 24, 2003, 4:21 AM

Post #1 of 5 (7281 views)
.+? probs... Can't Post

Hi...I have the following text;

<h2>WASHINGTON, May 23 (AFP) -</h2> US soldiers in Iraq seized a truck believed to be loaded with 2,000 gold bars worth as much as 500 million dollars during a ...

I am trying to remove the following;

<h2>WASHINGTON, May 23 (AFP) -</h2>

I have tried;

$back =~ s,<h2>(.+?)</h2>,,i

....and...

$back =~ s,<h2>.+</h2>,,i

... and ...

$back =~ s,<h2>?</h2>,,i

None of these seem to remove it. Am I doing it wrong, or is it just a problem with caching on my server, so I do not see the updates?

Cheers

Andy


Paul
Enthusiast

May 24, 2003, 7:04 AM

Post #2 of 5 (7278 views)
Re: [AndyNewby] .+? probs... [In reply to] Can't Post

Caching? Wink

$html =~ s|<h2>.+?</h2>||si;

...should work fine. If not, its something else in your code.


AndyNewby
Novice

May 24, 2003, 9:19 AM

Post #3 of 5 (7275 views)
Re: [Paul] .+? probs... [In reply to] Can't Post

Didn't work Frown

Still giving stuff like this back;

UNITED NATIONS, May 23 (AFP) - UN Secretary General Kofi Annan has chosen Sergio Vieira de Mello, currently the UN High Commissioner for Human Rights, as his special representative ... [more]


...and...

CRAWFORD, Texas, May 23 (AFP) - US President George W. Bush on Friday fueled speculation he may convey his first Middle East summit next month, saying he would meet ... [more]


Cheers

Andy
webmaster@ace-installer.com
http://www.ace-installer.com


Jasmine
Administrator

May 24, 2003, 3:54 PM

Post #4 of 5 (7273 views)
Re: [AndyNewby] .+? probs... [In reply to] Can't Post

Paul's answer worked for me as well:

$html =~ s|<h2>.+?</h2>||si;

Of the ones you provided, these worked:
$back =~ s,<h2>(.+?)</h2>,,i
$back =~ s,<h2>.+</h2>,,i

This one didn't because the ? was making the > optional and not looking for anything in between the h2 tags:
$back =~ s,<h2>?</h2>,,i


AndyNewby
Novice

May 26, 2003, 2:26 AM

Post #5 of 5 (7266 views)
Re: [Jasmine] .+? probs... [In reply to] Can't Post

Thanks. I got it working now. It was a stupid mistake (I had removed the <h2> tags *before* the regex.....lol)

Cheers

Andy
webmaster@ace-installer.com
http://www.ace-installer.com

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives