Regular Expressions with T-SQL Summary


By:
Summary

In this tutorial we looked at using regular expressions with alphabetic, numerical and special character data while looking at some applied examples where regular expressions may be a tool that we can use.  We’ve also reviewed the inverse of regular expressions: expressions that look for data where it doesn’t fit a character type.  From ETL to data parsing to identifying strict limits, whether we’re trying to identify data, or precisely limit data, we can use regular expressions if the situation calls for it.

Take the time to walk through each of the examples to get a better understanding of how you can use regular expressions when working with SQL Server using T-SQL.






Comments For This Article




Thursday, September 26, 2019 - 4:07:11 PM - Shortsky Back To Top (82581)

This is not Regex indeed. Very interesting, but not to be confused with Regex.


Thursday, May 16, 2019 - 3:47:40 AM - Moosey Back To Top (80099)

While not strictly Regex, I found this a very useful tutorial in using patern matching within SQL Server, thanks for going to the trouble of putting it together!


Friday, June 15, 2018 - 4:55:59 AM - Tim Back To Top (76228)

@Jonmcrawford

We can use some comparable expressions to a full regular expression library for matching certain patterns with T-SQL using the like operator. In this tutorial, we will practice using these expressions (referred to as regular expressions in the context only of T-SQL) for filtering price phrases involving alphabetic, numeric, and special characters. [1rst paragraph]


Thursday, June 14, 2018 - 8:53:03 AM - Jonmcrawford Back To Top (76219)

 

 Exactly agree with Darryll D. Petrancuri, LIKE matching does not use RegEx, and the tips/articles online that suggest it does have led me down the wrong path before, to great confusion. Please revise that within your tutorial, still very useful on how to employ pattern matching, but it's an important distinction.

 


Monday, May 21, 2018 - 5:45:57 PM - Tim Back To Top (75995)

@Darryll Thanks and as you note, through LIKE T-SQL supports a subset of expressions that are sufficient for addressing the use cases addressed in this tip and some similar use cases.  This tutorial shows how these can be used for these situations, though these expressions are not as comprehensive as what can be used in System.Text.RegularExpressions by comparison.

To avoid confusion if soneone thought every expression would be comparable, I've made an appropriate update.  Thanks again.


Friday, May 11, 2018 - 6:34:30 PM - Darryll D. Petrancuri Back To Top (75924)

 This is not RegEx.

The SQL Server Like operator does not support regular expressions. It supports a limited subset thereof, and to imply that you can achieve full regex capabilities natively is grossly misleading.















get free sql tips
agree to terms