Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Regex not matching all in DB

by Wonko the sane (Deacon)
on Jan 30, 2003 at 16:25 UTC ( #231366=note: print w/replies, xml ) Need Help??


in reply to Regex not matching all in DB

I agree that you are probably better off using HTML::Entities
The code you have should work for what you are trying to do.
The following snippet works as expected on your test line.
#!/usr/local/bin/perl -w use strict; my $line = q{<br>&lt;/pre&gt;<br>&lt;img src=http://blah.microsoft.com +/analog_sc/bp/_lessons_learned/2788_1.jpg&gt;<br>&lt;br&gt;<br>&lt;im +g}; print qq{LINE:[$line]\n}; tagremover( $line ); print qq{LINE:[$line]\n}; sub tagremover { $_[0] =~ s/&lt;/</g; $_[0] =~ s/&gt;/>/g; }
Outputs:
LINE:[<br>&lt;/pre&gt;<br>&lt;img src=http://blah.microsoft.com/analog +_sc/bp/_lessons_learned/2788_1.jpg&gt;<br>&lt;br&gt;<br>&lt;img] LINE:[<br></pre><br><img src=http://blah.microsoft.com/analog_sc/bp/_l +essons_learned/2788_1.jpg><br><br><br><img]
What are you getting in your $description var after the replacement? DOes your data have Newlines in it?

Wonko

Replies are listed 'Best First'.
Re: Re: Regex not matching all in DB
by Willman023 (Scribe) on Jan 30, 2003 at 19:21 UTC
    Thanks alot guys! Its not that my regex doesn't work at all it does get some, just not when its -&gt; or <br>&lt I saw no need to escape anything in my regex the & and semicolon aren't special at all. I guess I'll try HTML::Entities as suggested instead of writing a hundred regex's.

    bW
    Perl - the breakfast of Champions!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://231366]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2022-12-04 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?