hwassinger
asked on
parsing data in a function
I have a field ptage that contains the patients age formatted as XXXY
where XXX can be 1,2 or 3 digits and Y will be either D,M,Y
How can I parse out the XXX and the Y into separate fields?
e.g.
Num Alpha
21D = 21 D
3M 3 M
101Y 101 y
where XXX can be 1,2 or 3 digits and Y will be either D,M,Y
How can I parse out the XXX and the Y into separate fields?
e.g.
Num Alpha
21D = 21 D
3M 3 M
101Y 101 y
post sample values
This should help:
Dim strField As String
strField = "123D"
If (Len(strField) > 0) Then
MsgBox Right(strField, 1)
MsgBox Left(strField, (Len(strField) - 1))
End If
Dim strField As String
strField = "123D"
If (Len(strField) > 0) Then
MsgBox Right(strField, 1)
MsgBox Left(strField, (Len(strField) - 1))
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Have you read matthewspatrick's article on regular expressions? For the requirement you describe above, I would expect a pattern like:
With that, your number would be in group 1 and your letter code would be in group 2.
^(\d{1,3})([yYmMdD])$
With that, your number would be in group 1 and your letter code would be in group 2.