in reply to strip out anything inbetween brackets
$string =~ s/\(.*\)//;
Which would do the trick in this particular case, but would convert "this is a (blah) and this is not a (blah)" in "this is a ", which is why you should use a non-eager quantifier:
$string =~ s/\(.*?\)//;
This does the trick...
Don't forget, however, to use the /g switch (for global substitutions). Also, your example has the result as being "this is a" (notice there's no space after the a...)
If that's what you want, you just need to include \s* on both ends of your regular expression...
OTOH, that would turn "this is a (blah) bleh" into "this is ableh", which is probably not what you want... O:-)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: strip out anything inbetween brackets
by reasonablekeith (Deacon) on Apr 05, 2005 at 14:51 UTC | |
|
Re^2: strip out anything inbetween brackets
by jhourcle (Prior) on Apr 05, 2005 at 14:48 UTC | |
|
Re^2: strip out anything inbetween brackets
by Anonymous Monk on Apr 05, 2005 at 14:19 UTC | |
by cog (Parson) on Apr 05, 2005 at 14:24 UTC |