$_ = 'foo and bar and baz went to the sea.'; my @pairs = /(and)(?=\W*(\w+))/g; print join "#", @pairs;