Word delimiters

hlowe hlowe at me.com
Sat Jun 10 19:38:05 EDT 2017


Livecode defines a word as:

"A word is delimited by one or more spaces, tabs, or returns, or is enclosed
by double quotes."

Generally this works well but if I have text in which one or more words are
contained within either round brackets "(word1 word2)" or square brackets
"[word1 word2]" the paren characters are considered part of the word.

For example try this from the message box:

"answer word 4 of "word1 (word2 word3) [word4 word5]"
 the result is "[word4"
 
Thus searching for specific word chunks within text fails if the word is
contained within a round or square bracket.

For example:

repeat for each word tWord in "red (blue green) [orange purple]"
if tWord is "orange" then answer "found" 
end repeat

Though "orange" is a word (by general definition) in the text, it is not
found.

The same issue arises if there are certain punctuation characters at the end
of a word e.g "orange;"

Ideally one could define a set of comma-delimited characters that are
considered word delimiters in the same way that we can (temporarily) change
the itemDelimiter character:

e.g. set the WordDelimiters to "~,(,),{,},[,],;,:,comma, return,space,tab"

Similar to the itemDelimiter property, this property would be reset to the
default when the handler completes.

Perhaps there is already a solution to this that I don't know about? Yes,
one can preprocess the input text to remove parens and certain punctuation
characters but having the option for LiveCode to recognize them as word
delimiters would be more elegant (IMHO).

Henry



--
View this message in context: http://runtime-revolution.278305.n4.nabble.com/Word-delimiters-tp4715709.html
Sent from the Revolution - User mailing list archive at Nabble.com.




More information about the use-livecode mailing list