Link to home
Create AccountLog in
Avatar of ambuli
ambuliFlag for United States of America

asked on

Perl : How to remove a substring from a string

Hi Experts,

I have to print the portion of a string by removing anything before the word teststring in the following string.

this is: a long line teststring:  this portion is needed

I want to print the new string as: this portion is needed.
Thank you
ASKER CERTIFIED SOLUTION
Avatar of ravenpl
ravenpl
Flag of Poland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of wilcoxon
More efficient would be:

$value =~ s/^.*?teststring//;

as there is no reason to capture the string being removed.