Re: regex
- From: "jg" <junk@xxxxxxxx>
- Date: Sat, 13 Aug 2005 20:12:28 -0600
case sensitivity was part of the problem which I fixed with
RegexOptions.IgnoreCase
However there is still problem with my regex pattern,
I could test with simple one like "FEB", or
"((JAN)|(FEB)|(MAR)|(APR)|(MAY)|(JUN)|(JUL)|(AUG)|(SEP)|(OCT)|(NOV)|(DEC))"
and get the right answer but not
'([ADFJMNOS][ACEOPU][BCGLNPRTVY])"
In other word I got syntax problem with the month pattern
"Phil" <Phil@xxxxxxxxxx> wrote in message
news:ddlrd5$oau$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Hi jg,
>
> My 'only' comment would be whether you have commented out the line
> 'm.Index.ToString' and this is part of the commented previous line!
>
> Otherwise, your code looks good and should return your
> string.......assuming it is actually found. Just note that I don't know
> whether the match method is case sensitive. Not sure if this helps.
>
> Good luck, Phil
>
> "jg" <junk@xxxxxxxx> wrote in message
> news:eFV2lfDoFHA.3408@xxxxxxxxxxxxxxxxxxxxxxx
>>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.
>>
>>
>>
>>
>>
>>
>
>
.
- Follow-Ups:
- Re: regex
- From: Phil
- Re: regex
- Prev by Date: Re: PrintDocument with streamreader gives blank pages
- Next by Date: TreeView Help
- Previous by thread: Re: regex
- Next by thread: Re: regex
- Index(es):
Relevant Pages
|