Skip to content

Instantly share code, notes, and snippets.

View apachaves's full-sized avatar
💻
Crunching data...

Anderson Chaves apachaves

💻
Crunching data...
View GitHub Profile
@icheishvili
icheishvili / match.py
Created March 12, 2012 21:48
Faster automata-style string-matching
#!/usr/bin/env python
def match(needle, haystack):
"""Perform finite-automata style string matching."""
matches = []
nposition = 0
for index, char in enumerate(haystack):
if needle[nposition] == char:
nposition += 1