String Matching: The Ergodic Case