Custom Search

Thursday, October 21, 2010

Suppose I’m having a string wipro123xyz45 I need to get the value 12345 only from the string and the string could be changed randomly

Function RegExpTest(patrn, strng)
        Dim regEx, Match, Matches ' Create variable.
        Set regEx = New RegExp ' Create a regular expression.
        regEx.Pattern = patrn ' Set pattern.
        regEx.Global = True ' Set global applicability.
        Set Matches = regEx.Execute(strng) ' Execute search.
        For Each Match in Matches ' Iterate Matches collection.
              RetStr = RetStr & Match.Value' & vbCRLF
        Next
        RegExpTest = RetStr
End Function
a=(RegExpTest("[0-9]", "wipro123xyz45"))
msgbox(a)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.