Perl: How can I use regex?

I use this regular expression to search for patterns in the genome.

$string =~ /(?i)a+t?|(?i)t+/g 

To make it easier to read, I would like to change it so that it absorbs everything that matches, from 4 to 7 characters. Also, it should not spoil the variables $+[0] or $-[0] .

the way I conclude is to get a substring from a larger string file based on "$ + [0]" and "$ + [0]", I don’t want to print regular expressions I print huge lines of proofreaders, and I want matches stood out.

If you really need to see the code I'm working on, you can get it here

+4
source share
1 answer

With appropriate tests (for your correspondence and length (you may need groups of characters with quantifiers like {4.7}), without the contents of the example that remains for you), you can use eval substituton s/(match)/uc($1)/eg , which will take a matching string and capitalize it, then replace it with a replacement.

As always, read on perldoc perlre perldoc perlreref perldoc perlretut

As a side element, I always wondered if Genomes is a good candidate for Regexp::Grammars ?

+9
source

All Articles