Got more questions? Find advice on: ASP | SQL | XML | Windows
in Search
Welcome to RegexAdvice Sign in | Join | Help

Regular Expression code from ASP to ASP.NET 2.0

Last post 03-28-2008, 3:57 PM by mash. 1 replies.
Sort Posts: Previous Next
  •  03-21-2008, 6:04 PM 40574

    Regular Expression code from ASP to ASP.NET 2.0

    I have ASP Classic code I'm trying to convert to ASP.NET 2.0.  The code is:

    RegularExpressionObject = New Regex
    With RegularExpressionObject
        .Pattern = sString
        .IgnoreCase = True
        .Global = True

    End With

    expressionmatch = RegularExpressionObject.Execute(strCode)
    If expressionmatch.Count > nCount Then
       For Each expressionmatched In expressionmatch
           ' I add expressionmatched.Value to an array
       Next 

    I've Googled this, but all I can seem to find is regular expression validation.

    Diane 

  •  03-28-2008, 3:57 PM 40794 in reply to 40574

    Re: Regular Expression code from ASP to ASP.NET 2.0

    You have to use the System.Text.RegularExpression namespace

    VB.Net syntax

     Private Sub Test()
                Dim regex As String = "foo"
                Dim options As System.Text.RegularExpressions.RegexOptions = System.Text.RegularExpressions.RegexOptions.IgnoreCase
                Dim reg As System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex(regex, options)

                Dim expressionmatch as System.Text.RegularExpressions.MatchCollection = reg.Matches
                Dim expressionmatched   as System.Text.RegularExpressions.Match
                For Each expressionmatched In expressionmatch
                    ' I add expressionmatched.Value to an array
                Next

               
     End Sub


    Michael

    "In theory, theory and practice are the same. In practice, they are not."
    Albert Einstein
View as RSS news feed in XML