[Newbies] Re: ByteString>>match: greedyness of * ??
Kent Loobey
kent at uoregon.edu
Tue Jan 8 22:05:58 UTC 2008
On Tuesday 08 January 2008 13:03:22 Ch Lamprecht wrote:
> nicolas cellier wrote:
> > This behavior is squeakish, other Smalltalk match differently:
> >
> > VW: '**' match: 'e'. "true"
> > gst: '**' match: 'e'. "true"
> >
> > Anyway, this pattern matching is limited. How do you match a '*' itself?
> > I thought your example might be interpreted as an escape sequence, but
> > no, there is no escape in this simple matching.
> >
> > '**' match: '*'. "false"
> > '\*' match: '*'. "false"
> >
> > Try VBregex or another regex package.
> >
> > Nicolas
>
> Hi,
> thank you.
> In addition to the expressions below, I found, that #match: does not behave
> as stated by the comment given in the method definition itself:
>
> From ByteString>>match:
>
> "
> [snip]
> 'foo*baz' match: 'foo23baz' true
> 'foo*baz' match: 'foobaz' true <----
> 'foo*baz' match: 'foo23bazo' false
> 'foo' match: 'Foo' true
> 'foo*baz*zort' match: 'foobazort' false
> 'foo*baz*zort' match: 'foobazzort' false <----
> [snip]
> "
In general * means any character including no characters.
So the first one is foo any-character baz.
The third is false because of the "o" on the end. If you wanted it to work
you could put 'foo*baz*'.
I don't know why the last one wasn't reported as true.
>
> confused, Christoph
>
> > Ch Lamprecht a écrit :
> >> Hello,
> >>
> >> I found the following results for some expressions using #match:
> >>
> >> 'e' match: 'e'. "true"
> >> '*' match: 'e'. "true"
> >> '#' match: 'e'. "true"
> >>
> >> '*e' match: 'e'. "true"
> >> '*#' match: 'e'. "false"
> >> '**' match: 'e'. "false"
> >>
> >> '*' match: ''. "true"
> >> '**' match: ''. "false"
> >>
> >>
> >> Is this expected behavior?
> >> Looks like * is sometimes 'greedy', sometimes not. (Comparing 4 and 5)
> >> Thank you for any hints.
> >>
> >> Christoph
> >
> > _______________________________________________
> > Beginners mailing list
> > Beginners at lists.squeakfoundation.org
> > http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
More information about the Beginners
mailing list