S
Stephen O'D
Hi,
I can't believe I cannot get this to work, as it seems so simple, but I
am so far stumped.
I have a variable (two different cases):-
my $text = "foo_errors_bar";
my $text = "foo_errors_bar_errors_foobar";
I need to substitute the final 'errors' out of the string leaving me
with:-
$text = 'foo__bar';
$text = 'foo_errors_bar__foobar';
$text =~ s/errors(.+)$/$1/
Does not work, as it grabs the first 'errors'.
So I tried:-
$text =~ s/errors([^(?:errors)]+)$/$1/
Which does not work at all (I thought this would translate rougly into
english as "find errors followed by one or more not errors to the end
of the string").
Can anyone tell me what I need to do to match the final errors in a
string, and why my second attempt did not work (Is this because
negating a group of characters in this way does not behave in the way
you would expect? I cannot find any examples in the docs)?
Thanks,
Stephen.
I can't believe I cannot get this to work, as it seems so simple, but I
am so far stumped.
I have a variable (two different cases):-
my $text = "foo_errors_bar";
my $text = "foo_errors_bar_errors_foobar";
I need to substitute the final 'errors' out of the string leaving me
with:-
$text = 'foo__bar';
$text = 'foo_errors_bar__foobar';
$text =~ s/errors(.+)$/$1/
Does not work, as it grabs the first 'errors'.
So I tried:-
$text =~ s/errors([^(?:errors)]+)$/$1/
Which does not work at all (I thought this would translate rougly into
english as "find errors followed by one or more not errors to the end
of the string").
Can anyone tell me what I need to do to match the final errors in a
string, and why my second attempt did not work (Is this because
negating a group of characters in this way does not behave in the way
you would expect? I cannot find any examples in the docs)?
Thanks,
Stephen.