Sql喜欢RegEx [英] Sql Like to RegEx
本文介绍了Sql喜欢RegEx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有一种将函数(MSSQL)中的正则表达式转换为LIKE的好方法?
sproc并没有比这更复杂:
Is there a good way to convert Regular Expression into LIKE inside a Function (MSSQL)? The sproc does not get more complicated than this:
(country\=)(?<Country>[\w\d]+)(\&sessionid\=)(?<SessionId>.+)
这些组不会在LIKE中使用,它们出于其他目的。
The groups will not be used in the LIKE, they are there for another purpose.
我想在最近的一个sproc中使用它如:
I would like to use this inside a sproc late like:
SELECT * FROM [Table]
WHERE test_regex(regex, 'text') = 1
其中正则表达式是[Table]的一部分
Where the regex is a part of [Table]
推荐答案
使用CLR函数可以将正则表达式解析添加到SQL Server。这从SQL 2005及更高版本中是可能的。请参阅此处获取一个很好的示例。
It is possible to add Regular Expression parsing to SQL server, using a CLR function. This is possible from SQL 2005 and up. See here for a great example.
这篇关于Sql喜欢RegEx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文