is among the words AND find words

Pete pete at mollysrevenge.com
Wed Dec 21 13:12:30 EST 2011


The token keyword works with "time," and "time-bomb" (assuming you want to
find just "time").  I've found it to be really useful in a number of
circumstances in parsing out chunks of text from strings that don't fit the
standard word model - like SQL statements which can include commas,
parentheses, quotes, single quotes, and periods.  Many punctuation marks
are treated as separate tokens as well as anything delimited by a space,
return, tab, or semicolon.  Only drawback is that there is no tokenOffset
function so you have to write your own using a repeat loop to go through
the string.
Pete

On Wed, Dec 21, 2011 at 2:15 AM, Alex Tweedly <alex at tweedly.net> wrote:

> Hmmm ... what will happen to "there is time,enough for it" - NB no space
> before or after the comma.
>
> I think you *want* to find "time" in that case - but I'm not sure if you
> will by stripping out all non-letter characters from the word "time,enough".
>
> Would it not be simpler (and faster) to find the the word as a string, and
> then verify that the char before is not a letter, and that the char after
> it is not a letter ?
>
> but then, what about "find the time-bomb here" ?  Is time a word, or
> time-bomb a single, hyphenated word ?
> Oh well, you choose :-)
>
> -- Alex.
>
>
> On 21/12/2011 05:10, Jim Hurley wrote:
>
>> Think I will try something like this.
>>
>> Test to see if the word, as a string, is in the text.
>> If so, then strip out all characters not between "a" and "z" or "A" and
>> "Z"  and then check to see if the stripped-down word is the same as the
>> test word.
>>
>> That way I will find "time" even if it appears as "(time)" or "time." or
>> "time," or with quotes on either side, etc.
>>
>> I wonder what algorithm LC uses in "Find word(s)" to find only words.
>>
>> Jim Hurley
>>
>
>
> ______________________________**_________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/**mailman/listinfo/use-livecode<http://lists.runrev.com/mailman/listinfo/use-livecode>
>
>


-- 
Pete
Molly's Revenge <http://www.mollysrevenge.com>



More information about the use-livecode mailing list