I need to run a query against my SQL Server database using the below Regular Expression. This database exists on a development server, and I do not have access to enable CRL integration or create assemblies. Is there any other way to run a query that contains a Regular Expression against a SQL Server database?
If it is not possible, is it alternatively possible to formulate the below expression into a SQL Query?
The best solution I can come up with is to pull the table into a datatable using C#, do the necessary regex operations in C#, and then put it back into the database, but I'd really like to avoid that.
The regex: \d{4}(?=\D|$)(?<=(\D|^)\d{4}
EDIT: The SQL Query would need to take a string of any size with any alphanumeric characters in it and return an exactly 4 digit number. If there is a 5 digit number, it should not return 4 digits of that number.
Test Cases:
lis:xyz1257jd7=-1=-
&&12$*him1763&&whatwho
12344567xx1234xy000000
1874@45 &87 9876 abc123
Returns:
1.1257
2.1763
3.1234
4.9876