I am working on categorizing strings, and thought the RegExp could be the right tool for it.
The kind of strings I want to separate are of the following appearance:
@1|27|23|02|12
@1|27|23|02|01|@ZZZ
@1|27|23|02|08|0152829
@1|27|23|02|01|06180704
I want to be able to categorize each of these strings. Thats what I started with:
Function ColumnValue(RefColObject, ColumnObject, BaseRowIndex, BaseColumnIndex)
SAPString = RefColObject.SystemFullName
Msgbox SAPString
Set re = New RegExp
With re
.Pattern = "\@[0-9]\|[0-9][0-9]\|[0-9][0-9]\|[0-9][0-9]"
.IgnoreCase = False
.Global = False
End With
Set re2 = New RegExp
With re2
.Pattern = "\@[0-9]\|[0-9][0-9]\|[0-9][0-9]\|[0-9][0-9]\|[0-9]{7,8}"
.IgnoreCase = False
.Global = False
End With
If re2.Test(SAPString) Then
Msgbox "Mit SAP"
ElseIf re.Test(SAPString) Then
Msgbox "Nur Pfad"
End If
Set re = Nothing
End Function
My problems/questions..
When I test the string @1|27|23|02|01|06180704
with my RegExp re
it says true of course, can I tell the RegExp that after \@[0-9]\|[0-9][0-9]\|[0-9][0-9]\|[0-9][0-9]
there should not be anything more?
When I test my RegExp re2
with the string @1|27|23|02|01|06180704
, I don't get a true
back. In my understanding the last part of my RegExp re2
[0-9]{7,8}
should say that in the end of the string there must be a string of 7-8 numbers from 0-9. Where did I go wrong with my considerations here?
Thank you for your help community!!