Analog for regular expression '?' (preceding element optional) in T-SQL?

I am wondering if it is possible to translate a regex containing '?' (previous element optional) in a LIKE T-SQL template? Without any action on the part of the database. For example, "^31-?4" . I could divide it into several articles, but if the regex contains a lot? it is not so convenient.

+7
regex tsql
source share
1 answer

LIKE does not use regular expressions, and the template language that it uses does not have tokens and qualifiers, just a few placeholders :

 Wildcard character Description ------------------ ----------- % Any string of zero or more characters. _ (underscore) Any single character. [ ] Any single character within the specified range ([af]) or set ([abcdef]). [^ ] Any single character not within the specified range ([^af]) or set ([^abcdef]). 

So no, there is not what you are asking for.

+7
source share

All Articles