CLR Integration

  • 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
    whoisactive

  • 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.

Viewing 2 posts - 31 through 31 (of 31 total)

You must be logged in to reply to this topic. Login to reply