The Practice of Programming
Perl 6, 39 bytes



-&gt;\a{&amp;{?/&lt;{a}&gt;/}}o{S:g/&lt;-[.*$^]&gt;/'$/'/}


Try it online!

Simply evaluates the input as a regex, adding quotes to avoid any special characters Perl 6 uses. This takes input curried, as f(regex)(string), though it could be a lot shorter if I can just return a regex object.