A simple helper to extract values from a string based on a pattern.