> BlankHi everyone, > > I need some help for preventing greedy match..I want to get rid of the > words in paranthesis in the below text. When i use the code below i loose ' > john ' because it matches the last ' )' after recovery.. Is there a easy > way to avoid this?.. > > > $target='micheal (fields) john (recovery)'; > > $target=~s/\(.+\)/ /gi; > > print $target; > > output : micheal
#!/usr/bin/perl -w use strict; my $target='micheal (fields) john (recovery)'; $target=~s/\(.+?\)//gi; print "$target\n"; [localhost:~/Programming/Perl/Various code] tor% ./greedy micheal john [localhost:~/Programming/Perl/Various code] tor% This does however produce 2 spaces between the two names. So, you might also want to match the extra space before or after the parentheses. Tor -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]