[ale] Foolish Perl Question

Tommie M. Jones tj at atlantageek.com
Fri Mar 22 15:31:50 EST 2002




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.






More information about the Ale mailing list