Once upon a time?

Jim Ault JimAultWins at yahoo.com
Fri Feb 2 09:47:44 CST 2007


> put "once upon" is among the words of "once upon a time" = false (which
> surprised me!)
This shouldn't surprise you if you consider:
put "apple,grape" is among the items of "apple,grape,pear" = false
--since "apple,grape" is not an item, it is two of them
--just as "once upon" is not a word

If you want to detect the string "once upon" then
put space into s
put (s&"once upon"&s) is in (s&"once upon a time"&s)

--now the string can be located anywhere in the target phrase, beginning or
end, and return true.  No regex required.
Watch out for non white space delims such as "," or "."

get "once upon a time, the sky was blue"
replace "," with space
put space into s
put (s&"once upon"&s) is in (s&"once upon a time"&s)


Hope this helps
Jim Ault
Las Vegas


On 2/2/07 4:55 AM, "David Bovill" <david at openpartnership.net> wrote:
> 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)
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list