I am using this regular expression to find patterns in a genome.
$string =~ /(?i)a+t?|(?i)t+/g
To make the output easier to read I would like to modify it so it capitalizes anything it matches that is 4 to 7 characters long. Also it should not mess up the $+[0]
or $-[0]
variables.
the way i do the output is to get a sub-string from the larger string file based on the '$+[0]' 开发者_如何转开发and '$+[0]' i don't want to print out the regex matches i am printing out huge strings of correctors and i want the matches to stand out.
if you really need to see the code I'm working on you can get it here
With appropriate tests (for your match and for length (character groups with quantifiers like {4,7} are probably needed), without example content this is left to you) you could use an eval substituton s/(match)/uc($1)/eg
which would take the matched string and make it uppercase then replace the match with the replacement.
As always read more at perldoc perlre
perldoc perlreref
perldoc perlretut
As a sidenote, I have always wondered if Genomes are a good candidate for Regexp::Grammars
?
精彩评论