Perl - string matching issue

Posted by user2886545 on Stack Overflow See other posts from Stack Overflow or by user2886545
Published on 2014-06-09T09:13:33Z Indexed on 2014/06/09 9:24 UTC
Read the original article Hit count: 187

Filed under:
|

I have a problem I cannot understand. I have this string:

gene_id "siRNA_Z27kG1_20543"transcript_id "siRNA_Z27kG1_20543_X_1";tss_id "TSS124620"

And I want to change the gene_id. So, I have the following code:

if ($line =~ /;transcript_id "([A-Za-z0-9:\-._]*)(_[oxOX][_.][0-9]*)";/) {
            $num = $2;
            $line =~ s/gene_id "([A-Za-z0-9:\-._]*)";/gene_id "$1$num";/g;
            print $new $line."\n";
        }

The aim of my code is to change siRNA_Z27kG1_20543 for siRNA_Z27kG1_20543_X_1. However, my code does not produce that output. Why? I can't understand that.

My regex needs to be as it is because I match other strings (this time with success).

Thanks.

© Stack Overflow or respective owner

Related posts about regex

Related posts about perl