How Google Code Search Worked: Regex Matching with a Trigram Index (2012)
You can store a local search index of your code using <a href="https://github.com/google/codesearch" rel="nofollow">https://github.com/google/codesearch</a>, which uses this algorithm in the background.