[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Foolish Perl Question
- Subject: [ale] Foolish Perl Question
- From: tj at atlantageek.com (Tommie M. Jones)
- Date: Fri, 22 Mar 2002 15:31:50 -0500 (EST)
On Fri, 22 Mar 2002, Bob Kruger wrote:
> What I would like to do is come up with something that allows a
> wildcard. For example, right now:
>
> $line[7] =~ s/\[font color \=red\]//g;
>
> will strip out all of the "[font color = red]"
>
> What I would like to do is identify anything that starts with "[font" ,
> and strip everything until the next "]". So, if the character "*" did
> that, it would look something like:
>
This should do it
$line[7] =~ s/\[font color.*?\]//g;
. - matches any legal character.
*? Means nongreedy matching
Nongreedy matching is used so it will stop at the first ']' instead of the
last.
I think this maybe a perl only trick.
---
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.