• To david.rowland and Jeff Moden:

    With regards to performance, whether compared to LIKE / PATINDEX or even a custom SQLCLR function, please keep in mind that the main "win" here for Regular Expressions is functionality (and to a lesser degree: readability). Yes, a custom .Net string parsing function will be faster than the generalized Regular Expression functions, but there are pros and cons to most decisions. Likely people have a great variety of patterns to look for and it might not be feasible to have 30 or so custom functions. But it would be quite reasonable to do general matching via RegEx and when you find a place that truly needs performance, then make that situation a custom solution, just as you (david) did. I mean, if you absolutely need the performance then by all means take the approach that you did, but that does not take away from the overall benefit of people using Regular Expressions more.

    And regarding the PATINDEX comparison that Jeff asked for: along those same lines, even if the performance were slightly better with a combination of LIKE, PATINDEX, and SUBSTRING, for many patterns the sheer number of those functions required to do the same basic task as RegEx would render a straight T-SQL solution entirely unreadable or sometimes even impossible. Given that PATINDEX and LIKE can only do VERY simplistic patterns (maybe 3 of the 30+ RegEx functions) it would be hard to compare them fairly.

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR