在存储过程中使用正则表达式 [英] Using regular expression within a stored procedure
本文介绍了在存储过程中使用正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
启用除字符之外的所有输入的正则表达式模式是什么?到目前为止,这就是我所拥有的 -
What is the regular expression pattern that enables every input besides characters? So far this is what i have -
CREATE PROCEDURE Paging_Movies
@alphaChar char(1)
AS
if @alphaChar = '#'
select * from Movies where movies like '[0-9]%'
else
select * from Movies where movies like @alphaChar + '%'
推荐答案
如果您想要真正的正则表达式模式匹配,您将需要推出自己的 CLR UDF.此链接介绍了如何执行此操作:
If you want true regular expression pattern matching you will need to roll your own CLR UDF. This link goes over how to do that:
http://msdn.microsoft.com/en-us/magazine/cc163473.aspx
请记住,您只能在 SQL Server 2005 或更高版本中执行此操作.
Keep in mind that you can only do this in SQL Server 2005 or higher.
如果您只想要非 alpha,您可以这样做:
If you just want non-alpha you can do this:
'([^a-z])'
这里是 SQL Server like
的文档:
Here is the documentation for SQL Server like
:
http://msdn.microsoft.com/en-us/library/ms179859.aspx
这篇关于在存储过程中使用正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文