Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Regular Expressions .NET vs SQL

Author  Topic 

Billkamm
Posting Yak Master

124 Posts

Posted - 2006-01-12 : 10:48:46
Does anyone know of any way to convert regular expressions between .NET and SQL or way to use .NET regular expressions when created constraints on fields in a SQL Server Database.

The reason I ask is because right now I have to generate every regular expression twice. For example with ZIP Code:

.NET: \d{5}
SQL: LIKE '[0-9][0-9][0-9][0-9][0-9]'

When you get into more complex expressions that are protected more critical data than ZIP codes it is slightly annoying to have write it twice in two different formats.

Kristen
Test

22859 Posts

Posted - 2006-01-12 : 14:06:44
YOu can use a COM object from SQL Server to handle "richer" Regular Expressions. I'm not sure how ,NET does it, but VBScript uses an extgernal COM object, and that exact-same COM object can be used from SQL Server, which would then make the RegEx's "transparent".

SQL 2005 will presumably allow you to have an identical RegEx using some .NET CRL code "attached" to your SQL processes Server-Side.

http://sqlteam.com/item.asp?ItemID=13947
http://sqlteam.com/forums/topic.asp?TOPIC_ID=27205

Kristen
Go to Top of Page
   

- Advertisement -