Berkeley CSUA MOTD:Entry 10352
Berkeley CSUA MOTD
 
WIKI | FAQ | Tech FAQ
http://csua.com/feed/
2025/05/24 [General] UID:1000 Activity:popular
5/24    

2003/9/27-28 [Computer/SW/Languages/Perl] UID:10352 Activity:nil
9/26    in a perl script I'm trying to write a reg exp to replace a
        multiline block of text with another multiline block of text but
        can't seem to get it right. any advice? thanks.
        \_ example?
           \_ if he had an example he wouldn't need help, would he?
        \_ try subbing a variable for another variable, so you don't have
           to worry about how to escape newlines within s// expressions
        \_ i am trying to do the samething without much success.  I am trying
           to remove a mult-line text block with certain pattern (for example
           "Do You Yahoo?..."  Let me know if any of you have any cool idea
           on this supposely simple problem             -kngharv
        \_ http://tinyurl.com/oya1 [removes ads from yahoo msgs]
           I ran this through s2p, did a little cleanup, and have been
           using it in my procmail script for about a year.
        \_ Two things to keep in mind:
           1) You can't do this with a straight perl -pe 's/..../' from the
              command line (without -0777), so I'll assume you have the whole
              text to be substituted on in a scalar ($text or something).
           2) Use /s at the end of your regexp: $text =~ s/.../.../gs;
              This will make things like . match \n as well, so that your
              matches won't fail at the end of a line.  When in doubt, RTFM:
              perlre(1)     --dbushong
Cache (500 bytes)
tinyurl.com/oya1 -> info.ccone.at/INFO/Mail-Archives/procmail/Mar-2002/msg00284.html
Ive tested it on a 3k message mailspool and it stripped the advertisement off the tail of every message I had from yahoo or hotmail around 400. I went through the processed spools diffs and made sure it didnt go off the rails anywhere. The method of extending this for other ad banners should be clear, and if anyone does, Id be happy to get a copy of your sed regex. Im still limiting the recipe by From:, so I do still see ads in replies from other hosts, but Ill make it a blanket rule eventually.