in reply to s/// operator
The latter regex $test =~ s/"^mouse_(.+)"/$1/; is very close. The problem is that when you assign a string to a variable (eg: $test = "blah";), the quotes are stripped off. So it's the double-quote at the beginning of the regex that is breaking things. To further, ^ denotes the beginning of the string, so the " would never match even if there was one embedded in the string. Note though that the second double-quote at the end of the regex will allow the regex to match even though there isn't one in the string, because you capture everything (.+) up to it.
This works:
$test =~ s/^mouse_(.+)/$1/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: s/// operator
by perlUser345 (Acolyte) on Nov 19, 2015 at 19:31 UTC |