Page 1 of 1

Find a specific word in the sentence

Posted: Tue Aug 05, 2014 1:02 am
by Jellobus
Hi Gurus, 8)

I wonder how to delete specific word in the sentence? for example
In here, I like to delete word "failed" in the sentence below...let say the order of words will be kept changed and I like to delete word "failed" no matter where it is located.

"Over the last 13 months since being with LiveCode the strength and loyalty of this community has never failed to amaze me. We are a bigger & stronger community than we have ever been and that is very powerful."

Thanks in advance!

Louis

Re: delete word in the sentence

Posted: Tue Aug 05, 2014 1:28 am
by FourthWorld
The wordOffset function seems what you're looking for.

Re: delete word in the sentence

Posted: Tue Aug 05, 2014 3:21 am
by dunbarx
What Richard said.

That said, you may have to be careful if the word to delete is not the very first such instance in the text. Can you use the wordOffset function to determine if there is more than one instance, and what you might need to do in such a case?

Craig Newman

Re: Find a specific word in the sentence

Posted: Tue Aug 05, 2014 4:15 pm
by Jellobus
Hi, Richard and Craig :P

Here I will explain in details.. Just forget about deleting word... the real problem is this..

I like to make a head title(e.g "TITLE") bold, italic or colored in the field.

-There are multiple titles in one field.
-The head title is at the top of sentence separated by cr.
-The head "title" is among the continually changing sentences and the body sentences contain word "title".

Goal: make a title(e.g "TITLE") bold, italic or colored in the field. but not affect word "title" in the body sentence.

For example,

-------------------------------------
(cr)
TITLE1
(cr)
this is a field test. this is a title1 in the sentence but should not be bold, italic or colored.
(cr)
TITLE2
(cr)
this is a field test. this is a title2 in the sentence but should not be bold, italic or colored.
(cr)
TITLE3
(cr)
this is a field test. this is a title3 in the sentence but should not be bold, italic or colored.
(cr)
--------------------------------------

Cheers,


Louis

Re: Find a specific word in the sentence

Posted: Tue Aug 05, 2014 4:54 pm
by richmond62
If yout TITLES are all in uppercase and every other occurrence of that word is lowercose
then by using

set the caseSensitive to true

you should be able to distinguish between them.

Re: Find a specific word in the sentence

Posted: Tue Aug 05, 2014 4:56 pm
by dunbarx
What distinguishes the "title" as a title from "title" in the body of the text? It is the return, correct?

When you run the wordOffset function, you get the number of the word in the text. But what if you ran the function "offset"? Now you get the first character in the string. You know the length of the string you are finding, and so you can check the character which is one greater than that value. If it is a space, you know it is in the body. But if it is a cr, you know it is a title, and can work from there.

Do you see? The wordOffset function got you to your destination easily, but did not have the power to analyze deeply enough the immediate environment surrounding the found word. Write back if you get stuck, but this should be a hill of fun.

Craig

Re: Find a specific word in the sentence

Posted: Thu Aug 07, 2014 5:37 pm
by Jellobus
Thank you all!!

I made it work with offset function. :mrgreen:

Louis