visual basic

Topics: Pages: 34 (8352 words) / Published: Nov 10th, 2013
Function SubMatchTest(inpStr) Dim oRe, oMatch, oMatches Set oRe = New RegExp ' Look for an email address (not a perfect RegExp). oRe.Pattern = "(\w+)@(\w+)\.(\w+)" ' Get the Matches collection. Set oMatches = oRe.Execute(inpStr) ' Get the first item in the Matches collection. Set oMatch = oMatches(0) msgbox typename(oMatch) ' Create the results string. ' The Match object is the entire match - someone@example.com. retStr = "Email address is: " & oMatch & vbNewline ' Get the sub-matched parts of the address. ' someone retStr = retStr & "Email alias is: " & oMatch.SubMatches(0) retStr = retStr & vbNewline ' example retStr = retStr & "Organization is: " & oMatch. SubMatches(1) SubMatchTest = retStr
End Function

MsgBox(SubMatchTest("Please send mail to someone@example.com. Thanks!"))
Function SubMatchTest(inpStr) Dim oRe, oMatch, oMatches Set oRe = New RegExp ' Look for an email address (not a perfect RegExp). oRe.Pattern = "(\w+)@(\w+)\.(\w+)" ' Get the Matches collection. Set oMatches = oRe.Execute(inpStr) ' Get the first item in the Matches collection. Set oMatch = oMatches(0) msgbox typename(oMatch) ' Create the results string. ' The Match object is the entire match - someone@example.com. retStr = "Email address is: " & oMatch & vbNewline ' Get the sub-matched parts of the address. ' someone retStr = retStr & "Email alias is: " & oMatch.SubMatches(0) retStr = retStr & vbNewline ' example retStr = retStr & "Organization is: " & oMatch. SubMatches(1) SubMatchTest = retStr
End Function

MsgBox(SubMatchTest("Please send mail to someone@example.com. Thanks!"))Function SubMatchTest(inpStr) Dim oRe, oMatch, oMatches Set oRe = New RegExp ' Look for an email address (not a perfect RegExp). oRe.Pattern = "(\w+)@(\w+)\.(\w+)" ' Get the Matches collection. Set oMatches = oRe.Execute(inpStr) ' Get the first item in the Matches

You May Also Find These Documents Helpful

  • Visual Basic
  • Visual Basic
  • Visual Basic
  • Visual Basic
  • Visual Basic 6.0
  • Learning Visual Basic
  • Visual Basic Terms
  • IT visual basic textbook
  • Proposal for Visual Basic
  • Visual Basic Tutorial