[Newbies] Re: ByteString>>match: greedyness of * ??

Ch Lamprecht ch.l.ngre at online.de
Tue Jan 8 21:03:22 UTC 2008


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]
"

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



More information about the Beginners mailing list