Ignore punctuation when addressing word n of a string

Mark Brownell gizmotron at earthlink.net
Mon Aug 11 19:51:00 EDT 2003


On Monday, August 11, 2003, at 05:24  PM, Mark Powell wrote:

> I have a string such as "now, that is a string!"  But when I address 
> word n
> of the string, I get "now," (when n = 1) and "string!" for (when n = 
> 5).
> How can I point to a string and get only the nth word, without any
> contiguous punctuation getting in the way?
>
> Thanks in advance,
>
> Mark Powell

You can't. ( word 1), ( word 2), ( word 3)... are created by empty 
space between groups of chars. I would use replace to strip unwanted 
punctuation from your results.

replace  "," with empty in myChunk
replace  ";" with empty in myChunk
replace  quote with empty in myChunk
replace  ":" with empty in myChunk
replace  "!" with empty in myChunk

There's probably a slick way to do this with a Perl regEx though.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 821 bytes
Desc: not available
URL: <http://lists.runrev.com/pipermail/use-livecode/attachments/20030811/d946fe54/attachment.bin>


More information about the use-livecode mailing list