rohanan has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I want to use the replace only the first comma(,) from every line in a file. How can I do that? For the moment I have this
which only gives me the output as ABC,XYZ PERL IS AWESOME, INNIT But I am expecting- ABC,XYZ PERL IS AWESOME INNIT$string1 = "ABC,XYZ PERL IS, AWESOME, INNIT"; $string1 =~ s/(,[^,]*),/$1/gi; print "The resulting value is : $string1 \n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replace only selected characters
by hbm (Hermit) on Oct 14, 2011 at 18:39 UTC | |
by rohanan (Novice) on Oct 14, 2011 at 18:58 UTC | |
by rohanan (Novice) on Oct 14, 2011 at 21:41 UTC | |
by AnomalousMonk (Archbishop) on Oct 16, 2011 at 02:08 UTC | |
by Anonymous Monk on Oct 14, 2011 at 23:23 UTC | |
|
Re: Replace only selected characters
by herveus (Prior) on Oct 14, 2011 at 18:04 UTC | |
|
Re: Replace only selected characters
by johngg (Canon) on Oct 14, 2011 at 22:21 UTC | |
|
Re: Replace only selected characters
by AnomalousMonk (Archbishop) on Oct 16, 2011 at 02:56 UTC | |
|
Re: Replace only selected characters
by johngg (Canon) on Oct 17, 2011 at 13:21 UTC | |
by hbm (Hermit) on Oct 17, 2011 at 13:37 UTC | |
by rohanan (Novice) on Oct 17, 2011 at 16:23 UTC |