Matchchunk problem?
David Vaughan
drvaughan55 at mac.com
Wed Feb 6 19:30:01 EST 2002
Dave
Thanks for that. The regex part is no problem. Not immediately finding
the form of it I assumed it was primitive DOS-like stuff (I should have
read your sign-off line!) but the bit about enclosing it in parentheses
to capture the values was the crucial part I missed. Thanks again.
David
On Thursday, February 7, 2002, at 12:05 , Dave Cragg wrote:
> At 9:41 pm +1100 6/2/02, David Vaughan wrote:
>> The following script:
>> put "frog frog" into avar
>> put 1 into x
>> put 1 into y
>> get matchchunk(avar,"F*g",x,y)
>> put it && x && y
>>
>> returns "true " ...so what happened to the chunk values expected
>> in "x" and "y" ?
>> What I was REALLY trying to test was whether it would return in x
>> and y "1 4" or "1 9", but now I would love to know why I get neither
>> (matchtext fails similarly). What have I done wrong?
>>
>
> This regex stuff needs a twisted mind to master. :)
>
> Two problems with the script:
>
> 1. The regular expression "F*g" is trying to match "any number of F's ,
> including none" followed by a "g". This means if there is a "g"
> anywhere in the text, it will match and thus return true.
>
> I think you want "F.*g" ("F" followed by any number of characters
> followed by "g")
>
> 2. To get values returned in the variables, you need to enclose the
> relevant part of the regex in parentheses.
>
> on mouseUp
> put "frog frog" into avar
> put 1 into x
> put 1 into y
> get matchchunk(avar,"(F.*g)",x,y)
> put it && x && y
> end mouseUp
>
> It returns "true 1 9"
>
> Cheers
>
> Dave Cragg
> (Revolution --It's got the power)
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
More information about the use-livecode
mailing list