I need to remove every thing from a line in Perl up to a specific word .
suppose i have these 3 lines
Helicobacter Contig1
Helicobacter contig1
Helicobacter .Contig1
I want to have contig1 or Contig 1
I have tried
$test=s/^(.*?)^(contig|Contig)//g;
but it is not working. Any idea?
remove the second
^your regex should be
s/^(.*?)(?=contig|Contig)//g;the
.*?is non-greedy, so it will stop as soon as it can (i.e when it sees contig or Contig). you could also use the\imodifier to make the match case insensitive, so you don’t have to check for two different strings.