Substituting part of words in Perl regex -


given 2 text:

$mir1 = 'microrna-9a'; $mir2 =  'microrna10a'; $mir3 =  'microrna3a'; 

i want change to:

mir-9a mir-10a mir-3a 

in principle i'd replace variation microrna part mir- there single regex that?

i tried not sure how capture digit part.

my $mirnew = $mir =~ s/microrna(\d+)/mir-/gi; 

you need capture words, not digits after hyphen. backreferecence capture group, use $1:

s/microrna-?(\w+)/mir-$1/gi; 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -