Avatar of ambuli
ambuli
Flag 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
Perl

Avatar of undefined
Last Comment
wilcoxon

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ravenpl

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
wilcoxon

More efficient would be:

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

as there is no reason to capture the string being removed.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck