$word = qr[[a-zA-Z']+];; $sep = qr[[ \t.,!?]+];; $n=10; $match = 'match'; $re = qr[((?:$word$sep){$n}\Q$match\E(?:$sep$word){$n})];; print $para =~ $re;; want to extract n words on either side of the match. I am sure modules such as Plucene or KinoSearch already