in reply to Pattern searching allowing for mis-matches...

Something like this?

$seq = 'TGTGTGTGTGTG';; @tests = qw[ TX TXXX ];; for my $test ( @tests ) { ( my $re = $test ) =~ tr[X][.]; print "'$1'" while $seq =~ m[(?=($re))]g; };; 'TG' 'TG' 'TG' 'TG' 'TG' 'TG' 'TGTG' 'TGTG' 'TGTG' 'TGTG' 'TGTG'

Replacing your 'X's with '.'s gives you a wildcarding ability.

By placing the capture inside a lookahead, the matchpoint will only be advanced by one position after each match, rather than the length of the match. That allows overlapping matches to be found.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"I'd rather go naked than blow up my ass"