[Newbies] Re: ByteString>>match: greedyness of * ??
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
> 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:
> '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 <----
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
More information about the Beginners