ddrew78 has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I am in need of a rather unique solution. I have a string such as V12345:name_test or V12345_name_testWhat I need is that, if there is a "_" after the numbers, to replace it with ":", but if the ":" already exists, any subsequent "_" should remain as is. So "V12345_name_test" should be changed to "V12345:name_test", but "V12345:name_test" should remain unchanged. I've tried several different ways to 'sed' it, but can't get it to work correctly. As usual, any wisdom is greatly appreciated.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: replace first occurance if it doesn't already match
by toolic (Bishop) on Mar 10, 2017 at 16:26 UTC | |
by ddrew78 (Beadle) on Mar 10, 2017 at 16:32 UTC | |
|
Re: replace first occurance if it doesn't already match
by hippo (Archbishop) on Mar 10, 2017 at 16:34 UTC | |
|
Re: replace first occurance if it doesn't already match
by haukex (Archbishop) on Mar 10, 2017 at 16:32 UTC | |
|
Re: replace first occurance if it doesn't already match
by thanos1983 (Parson) on Mar 10, 2017 at 16:39 UTC |