You don't need to update our function... you just need to add a slash to your regular expression. What regular expression were you using?
This solution won't work if you meant to have a ? identifier as an optional character, which is what a ? means in a regular expression.