Replaces regex with custom function.