swissknife has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks,
I want to achieve following. I have a string called bge1 and I want to convert it to bge:1. to make it more specific, search the substring in the end of string and if it is number replace it with :number. I am trying following
my $Interface = bge1; $Interface =~ s/[0-9]\$/:\$&/;
but still result is bge1
what is wrong with it?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: find a substring using regex and then replace it
by toolic (Bishop) on May 02, 2016 at 14:21 UTC | |
|
Re: find a substring using regex and then replace it
by hippo (Archbishop) on May 02, 2016 at 14:24 UTC | |
by johngg (Canon) on May 02, 2016 at 16:08 UTC |