[ale] Foolish Perl Question

Fletch fletch at phydeaux.org
Fri Mar 22 15:15:30 EST 2002


>>>>> "Bob" == Bob Kruger <krugerb at benning.army.mil> writes:

[...]
    Bob> $line[7] =~ s/\[font color \=red\]//g;

        Actually the = doesn't need to be escaped.</pedantic>


    Bob> What I would like to do is identify anything that starts with
    Bob> "[font" , and strip everything until the next "]".  So, if
    Bob> the character "*" did that, it would look something like:

        $foo =~ s/\[font(?:[^\]]+)\]//g;


        Of course handling anything fancier (for something more like
HTML, where you could have quoted attributes or comments or . . .)
would require a parser rather than just a regexp.


        See also the Text::Balanced and Regexp::Common modules on
CPAN, perldoc perlre, and perldoc -q 'remove HTML'.


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
770 933-0600 x211(w)  |  scary questions." -- Jules                =(___)=
                      |                                               U

---
This message has been sent through the ALE general discussion list.
See http://www.ale.org/mailing-lists.shtml for more info. Problems should be 
sent to listmaster at ale dot org.






More information about the Ale mailing list