Hi,
Am am using regex to find numbers matching certains patterns in directory names. These numbers will be either 8 or 10 chars in length.
This is working fine. The problem I'm having is that if the function finds a number that begins with zero, when I assign that number to an integer, the zero is stripped of.
For example,
If my path is:
C:\someDir 01234567 blah blah\etc etc
I pass this into my RegEx function.
Dim myInt as integer = RegEx("C:\someDir 01234567 blah blah\etc etc")
The number is found and reported correctly within the method (mEight.Value) but as soon as it's assigned to the int the zero is stripped off.
E.g myInt = 1234567 instead of 01234567
I'm probably doing something realy dumb but just can't see what it is.
Thanks.
Am am using regex to find numbers matching certains patterns in directory names. These numbers will be either 8 or 10 chars in length.
VB.NET:
Private Function RegEx(ByVal CurrPath As String) As Integer
'Uses regex to see if the directory has a valid number.
Dim mTen As Match = regexTen.Match(CurrPath)
Dim mEight As Match = regexEight.Match(CurrPath)
If mTen.Length > 1 Then
'Return an 10 character number
Return mTen.Value
ElseIf mEight.Length > 1 Then
'Return an 8 character number
Return mEight.Value
End If
End Function
For example,
If my path is:
C:\someDir 01234567 blah blah\etc etc
I pass this into my RegEx function.
Dim myInt as integer = RegEx("C:\someDir 01234567 blah blah\etc etc")
The number is found and reported correctly within the method (mEight.Value) but as soon as it's assigned to the int the zero is stripped off.
E.g myInt = 1234567 instead of 01234567
I'm probably doing something realy dumb but just can't see what it is.
Thanks.