in reply to How to insert a "/" within a string?
my $str = 'ABCOPCOGNHVCOHL'; my $index = 0; while (($index = index($str, 'CO', $index)) > -1) { substr $str, $index, 2, 'C/O'; } print "$str\n"; __END__ ABC/OPC/OGNHVC/OHL
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to insert a "/" within a string?
by rovf (Priest) on Feb 21, 2012 at 13:11 UTC | |
|
Re^2: How to insert a "/" within a string?
by GrandFather (Saint) on Feb 21, 2012 at 19:41 UTC |