J
jg
I made a mistake somewhere in my vb code and I look, check and read against
the articles and help on regex, I still can't find the mistake I made.
I know my test string and the test patterns works, because I used on a vs.
script to check. I also believe I foolwed followed the regex syntax for
dotnet.
here is the source code for the function and testing
Public Function regtest(ByVal StringIn As String, ByVal patrn As
String) As Integer
' Create a new Regex object.
Dim r As New Regex(patrn)
' Find a single match in the input string.
Dim m As Match = r.Match(StringIn)
If m.Success Then
' Print out the character position where a match was found.
' (Character position 3 in this case.)
' Console.WriteLine("Found match at position " &
m.Index.ToString())
regtest = m.Index
else
Return -1
End If
End Function
The values for StringIn is "Mon, 2005-Feb-13 and some stuff"
for patrn is
"(\b([1-3][0-37-9]){0,1}[0-9][0-9][ -](([JFMASOND][AEPUCO][NBRYNLGPTVC]([A-Z]{0,6}))|([01]{0,1}[0-9]))[
-][01]{0,1}[0-9])"
The function regtest should return a number of 5 , at least not minus 1
which is what I got
Your help spotting the error is greatly appreciated.
Thank you for your time.
the articles and help on regex, I still can't find the mistake I made.
I know my test string and the test patterns works, because I used on a vs.
script to check. I also believe I foolwed followed the regex syntax for
dotnet.
here is the source code for the function and testing
Public Function regtest(ByVal StringIn As String, ByVal patrn As
String) As Integer
' Create a new Regex object.
Dim r As New Regex(patrn)
' Find a single match in the input string.
Dim m As Match = r.Match(StringIn)
If m.Success Then
' Print out the character position where a match was found.
' (Character position 3 in this case.)
' Console.WriteLine("Found match at position " &
m.Index.ToString())
regtest = m.Index
else
Return -1
End If
End Function
The values for StringIn is "Mon, 2005-Feb-13 and some stuff"
for patrn is
"(\b([1-3][0-37-9]){0,1}[0-9][0-9][ -](([JFMASOND][AEPUCO][NBRYNLGPTVC]([A-Z]{0,6}))|([01]{0,1}[0-9]))[
-][01]{0,1}[0-9])"
The function regtest should return a number of 5 , at least not minus 1
which is what I got
Your help spotting the error is greatly appreciated.
Thank you for your time.