Ratna_Ranjan has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks
I am trying to split a string using regex.Here is the code i tried and the output that i get and the output i want.
#!/usr/bin/perl my $var='Aur S-P 250 Pre (Chlorine + cillin (cilli G caine) + Sulfate) +'; my @pos=split(/\s\(/,$var); for(@pos) { print "$_\n"; }
output i get
Aur S-P 250 Pre Chlorine + cillin cilli G caine) + Sulfate)
output i want
Aur S-P 250 Pre Chlorine + cillin (cilli G caine) + Sulfate
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex splitting
by jethro (Monsignor) on Nov 19, 2009 at 22:15 UTC | |
by keszler (Priest) on Nov 19, 2009 at 22:35 UTC | |
by Ratna_Ranjan (Novice) on Nov 19, 2009 at 22:45 UTC | |
by graff (Chancellor) on Nov 19, 2009 at 23:12 UTC | |
by jethro (Monsignor) on Nov 19, 2009 at 23:28 UTC | |
by keszler (Priest) on Nov 19, 2009 at 23:11 UTC | |
|
Re: regex splitting
by colwellj (Monk) on Nov 19, 2009 at 22:34 UTC |