/ Published in: VB.NET
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
''' <summary> ''' Parses string matching regular expression ''' </summary> ''' <param name="_string">String to be parsed</param> ''' <param name="_regularExpression">Regular expresion to match</param> ''' <returns>String array matching regular expression</returns> ''' <remarks></remarks> Public Function ParseByRegex(ByVal _string As String, ByVal _regularExpression As String) As String() Dim regex As New Regex(_regularExpression, RegexOptions.IgnoreCase Or RegexOptions.Singleline) Dim matches As Match = regex.Match(_string) If (matches.Success) Then Dim stringArray(matches.Groups.Count - 2) As String 'Skips 0 because regex.Match(0) is original string For i = 1 To matches.Groups.Count - 1 stringArray(i - 1) = matches.Groups(i).ToString Next Return stringArray End If Return Nothing End Function