So I have regular expressions working in my VBA code. For the example input below I would like to match the following:
Input - FNB 3.875 2/10 30 /296 ( 5/10) 5YR \End Input What I would like matched 2 and 10 and 5 from 5YR
Input - MCR 4.50 1/15 376/36 ( 5/5 ) \End Input 10Y What I would like matched 376 and 36 and 10 from 10YR
Input - FNB 5.00 4/15 396/39 ( 5/10) \End Input 10Y What I would like matched 396 and 39 and 10 from 10YR
This is what I currently have:
Dim objRegExp As RegExp
Dim objMatch As Match
Dim colMatches As MatchCollection
Dim RetStr As String
Dim myarray
Dim Txt As String
RegExp = " "
'Pattern for Bid/Offer
mypattern = "\w+|w/d|d+\b (d|s|d+s/d+)|(s|d|d+)')'\B\b(d+|d)Y|YR"
'Create a regular expression object.
Set objRegExp = New RegExp
'Set the pattern by using the Pattern property.
objRegExp.Pattern = mypattern
'Set Case Insensitivity.
objRegExp.IgnoreCase = True
'Set global applicability.
objRegExp.Global = True
'Test whether the String can be compared.
If (objRegExp.Test(Lkp) = True) Then
Set colMatches = objRegExp.Execute(Lkp) ' Execute search.
Set oMatch = colMatches(0)
' Create the results string.
RetStr = RetStr & oMatch.SubMatches(0)
RetStr = RetStr & oMatch.SubMatches(1)
SubMatchTest = RetStr
MsgBox SubMatchTest
End If
Nothing Appears in the Return String!
Enter your message below
Sign in or Join us (it's free).