Returns an iterator function that returns the next captures from pattern over the string s each time it's called.