Hi,
if I have a value of a record, example: "LU_ATTRIB:LUTYPE:A1_VALUES"
My goal is, using regular expressions, to come to 3 variables comming from that record, namely: LU_ATTRIB, LUTPE and A1_VALUES in the variables field1, field2, field3.
I tried the following code:
However, when I run this code it bugs on the line "field2 = matches(1)".
By checking the "number" of matches using an addwach-method, it returns the value 1. But why? Because my regular expressions pattern:
"([A-Za-z0-9_]*)" if looking for any possible matches for wordcharacter (inculding underscore)
So for "field", the code finds the match " LU_ATTRIB". However, for field1 and field2 this doesn't work.
If I understand the principal of regular matches, I don't think I have to work with submatches?
Somebody can help?
Thanks a lot on forehand!
if I have a value of a record, example: "LU_ATTRIB:LUTYPE:A1_VALUES"
My goal is, using regular expressions, to come to 3 variables comming from that record, namely: LU_ATTRIB, LUTPE and A1_VALUES in the variables field1, field2, field3.
I tried the following code:
Code:
Function regexpparts(inputfield As String) As String '
Dim matches, field, reffield, number
Dim regEx As Object
Set regEx = CreateObject("vbscript.regexp")
With regEx
.Pattern = "([A-Za-z0-9_]*)"
.Global = False
End With
Set matches = regEx.Execute(inputfield)
number = matches.Count
field = matches(0)
field2 = matches(1)
field3 = matches(2)
Set matches = Nothing
Set regEx = Nothing
End Function
However, when I run this code it bugs on the line "field2 = matches(1)".
By checking the "number" of matches using an addwach-method, it returns the value 1. But why? Because my regular expressions pattern:
"([A-Za-z0-9_]*)" if looking for any possible matches for wordcharacter (inculding underscore)
So for "field", the code finds the match " LU_ATTRIB". However, for field1 and field2 this doesn't work.
If I understand the principal of regular matches, I don't think I have to work with submatches?
Somebody can help?
Thanks a lot on forehand!