Not sure if you intend on keeping these utility functions, but if you do, please consider adding comments explaining semantics (especially edge cases, e.g., what happens if it can't find the pattern), types and descriptions of inputs, and the return values.