Add flags option to toRegExp method