Once upon a time?
Jim Ault
JimAultWins at yahoo.com
Sat Feb 3 02:06:34 EST 2007
I apologize for my first reply.
A phone call came in before I wrote the reply, then I did it from my
recollection of the problem, and did not re-read the email carefully.
Disregard it because it does not address the problem (yes it is a hectic
Friday)
On 2/2/07 4:55 AM, "David Bovill" <david at openpartnership.net> wrote:
> put "once upon" is among the words of "once upon a time" = false (which
> surprised me!)
>
> put "once,upon" is among the items of "once,upon,a,time" = true
>
> set the wholeMatches to true
> set the itemDelimiter to space
> put "once upon" is among the items of "once upon a time" = true
>
> but with 2 spaces:
>
> set the wholeMatches to true
> set the itemDelimiter to space
> put "once upon" is among the items of "once upon a time" = false
>
> Is there a simple way to avoid regular expressions here? The aim is to be
> able to detect the exact two words together, but tolerant of variable white
> space.
>
> Something like this works but is ugly:
>
> put "(?mi)\W*once\s+upon\s+.*" into regularExpression
> put matchChunk(" once upon a time", regularExpression)
I think the key limitation you put forth is 'white space' and you could
convert all white space runs to one space char
put space into P
put replaceText("once upon a time","\s+",P) into cleanVar
put P&"once upon"&P is in P&cleanVar&P = true
--The reason for using a pad char is that you will find that
put "once upon" is in "put the wall sconce upon the workbench"
This will avoid having to construct ugly regex that depends on the phrase
you are testing.
Hopefully this answer will address you actual question.
Jim Ault
Las Vegas
More information about the use-livecode
mailing list