Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««1234

CLR Integration Expand / Collapse
Author
Message
Posted Sunday, June 22, 2008 11:18 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, July 18, 2014 7:02 AM
Points: 1,140, Visits: 701
You add it to the SqlFunctionAttribute in the C# code:

public partial class CTSStoredProcs
{
[Microsoft.SqlServer.Server.SqlFunction(IsDeterministic=true, IsPrecise=true)]
public static SqlBoolean RegExValidate(
SqlString expressionToValidate, SqlString regularExpression)
{
Regex regex = new Regex(regularExpression.Value);

return regex.IsMatch(expressionToValidate.Value);
}
}


... nothing different on the T-SQL side.


--
Adam Machanic
SQL Server MVP
SQLblog.com: THE SQL Server Blog Spot on the Web
Post #521434
Posted Saturday, September 5, 2009 4:10 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, April 16, 2013 7:20 AM
Points: 11, Visits: 90
good day sirs and madam,

i badly needed help.. i have this regular expression

^(?!.*--)[A-Za-z\d-]+$

it accepts alphanumeric character optionally a dash (single dash only, not consecutive dash) for exampl:

it accepts:
12a-3c-4f3fg
12ertgg2
1-2-3-3-4-3
dffgsfg
d-f-f-g-s-f-g

it does not accept:
12-3c-4f&3fg
12e%rt-gg2
d--f-f-g-s-f-g
1-2-3-3-4--3

now i have problem, i cant find any in the .net that accepts the above valid expression with space-a non consecutive space. meaning the it needs to accept alphanumeric with optionally a non-consecutive dash and optionally a non-consecutive space.

can someone help please.



Post #783298
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse