5

There are some searches that you just can't do without regex support, but...

AFAIK SQL Server doesn't support regex, but support can be added by creating CLR functions.

Has this been done?

If so, what are the function names?
If not, can it be done?

Of course, any such functions that exist should be noted on the help page.

1

1 Answer 1

8

The CLR is not enabled on the SEDE SQL Server instance, and won't be for security and performance reasons.

11
  • And there's no other way to do regex (I'm not an SQL Server aficionado)?
    – Bohemian
    Commented Mar 10, 2014 at 15:12
  • @Bohemian You can do string matches, but no regex patterns, no - not in the current version. Commented Mar 10, 2014 at 15:12
  • And doing pretty much all string operations on Stack Overflow's Posts table is prohibitively expensive anyway, unless you can narrow down your search space first.
    – Tim Stone
    Commented Mar 10, 2014 at 15:18
  • What about the API, Nick? Any way to filter by regex in there? Commented Mar 10, 2014 at 15:21
  • @ShadowWizard nope, we do not (nor do most sane) allow arbitrary regexes to be run on our servers. Commented Mar 10, 2014 at 15:26
  • Fair enough, just wanted to make sure. Commented Mar 10, 2014 at 15:28
  • 2
    @NickCraver - I don't see that allowing arbitrary regex's is any more dangerous than allowing arbitrary SQL. A badly written query could consume a lot of resources anyway. Commented Mar 10, 2014 at 15:30
  • 1
    @MartinSmith that's why queries have a MaxDOP and timeout set. Commented Mar 10, 2014 at 15:31
  • But the timeout would cancel any queries with catastrophically back tracking regex's too. Commented Mar 10, 2014 at 15:32
  • 1
    @MartinSmith the CLR engine has different constraints, it's not an immediate cleanup. You can argue how "not that bad" it is if you want, but that's not a great argument for it. What would you want to regex against? It's almost always the post bodies, which would timeout anyway. Commented Mar 10, 2014 at 15:34
  • Yep. Good point. Commented Mar 10, 2014 at 15:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .