perl - Pattern matching consecutive characters -
i have list of strings search through , ignore contain or g characters occur more 4 times consecutively. instance, ignore strings such tcaaaatc or gctggggaa.
i've tried:
unless ($string =~ m/a{4,}?/g || m/g{4,}?/g) { something; }
but error message "use of uninitialized value in pattern match (m//)".
any suggestions appreciated.
by writing
|| m/g{4,}?/g
you implicitly testing $_
against regex. but, $_
not initialized, error.
write
unless ($string =~ m/a{4}/ || $string =~ m/g{4}/)
instead (note simplifications made regex), or, single expression,
unless ($string =~ m/a{4}|g{4}/)
Comments
Post a Comment