Memoizes the regular expressions for path matching