Re: regex



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.
>>
>>
>>
>>
>>
>>
>
>


.



Relevant Pages

  • Re: Regex question
    ... structure of the date you're trying to extract. ... For example, in Regex you can ... pattern that will ensure a valid date within the range allowed by T-SQL ... valid date from a string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: How do I shorten or split this function
    ...    (scan regex string) ... Instead of field-name you mean field-type. ... it doesn't test the string to see if it's of the suitable form for the ... corresponding field of the pattern. ...
    (comp.lang.lisp)
  • Re: Expressing AND, OR, and NOT in a Single Pattern
    ... much better because the esoterica of regex can make the desired ... results hard to figure out and the bugs in the pattern even harder to ... The only thing I'd do differently to these patterns is add an anchor ... long strings, when the pattern was at the end of the string. ...
    (comp.lang.perl.misc)
  • Re: Interaction between two strings
    ... then the string XYZC should give a match. ... > string that is supplied separately from the regex. ... $patterns, you splice them all into one very big $pattern. ... Doing this is immensely faster than iterating through an array or the like: ...
    (comp.lang.perl.misc)
  • Re: Predicting the Future and Kolmogorov Complexity
    ... Predictability is based on the pattern itself. ... addition to the string. ... For any prediction scheme, there are computable strings that show no ... Out of this hole comes a ~2 cm blue marble followed by a red ...
    (talk.origins)

Quantcast