Converemon
New Member
- Joined
- May 23, 2014
- Messages
- 15
I have a string and a pattern. If a substring of the string is found in the pattern, the string is no longer valid. I would like to return a message stating which substring was found in the pattern. I appreciate any help.
String: K22+L09+P88+Q12+J56
Pattern: (N75|X02|A21|U67|L09|...)
Output Should Be: "J56 is an invalid code. Blah-Blah"
Code to test string against pattern:
My only problem is returning which code was found in the pattern. I am willing to consider different approaches as well.
String: K22+L09+P88+Q12+J56
Pattern: (N75|X02|A21|U67|L09|...)
Output Should Be: "J56 is an invalid code. Blah-Blah"
Code to test string against pattern:
Code:
Function Test_OPC(sCode, sPattern) As Boolean
Dim RegX As Object
Dim RegMC
Set objRegX = CreateObject("VBScript.RegExp")
With objRegX
.Pattern = sPattern
If .Test(sCode) Then
Set RegMC = .Execute(sCode)
Test_OPC = True
Else
Test_OPC = False
End If
End With
End Function
My only problem is returning which code was found in the pattern. I am willing to consider different approaches as well.