Find a specific word in the sentence

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Jellobus
Posts: 317
Joined: Tue Dec 10, 2013 2:53 pm

Find a specific word in the sentence

Post by Jellobus » Tue Aug 05, 2014 1:02 am

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
Last edited by Jellobus on Tue Aug 05, 2014 4:17 pm, edited 1 time in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: delete word in the sentence

Post by FourthWorld » Tue Aug 05, 2014 1:28 am

The wordOffset function seems what you're looking for.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: delete word in the sentence

Post by dunbarx » Tue Aug 05, 2014 3:21 am

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

Jellobus
Posts: 317
Joined: Tue Dec 10, 2013 2:53 pm

Re: Find a specific word in the sentence

Post by Jellobus » Tue Aug 05, 2014 4:15 pm

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

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10102
Joined: Fri Feb 19, 2010 10:17 am

Re: Find a specific word in the sentence

Post by richmond62 » Tue Aug 05, 2014 4:54 pm

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.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: Find a specific word in the sentence

Post by dunbarx » Tue Aug 05, 2014 4:56 pm

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

Jellobus
Posts: 317
Joined: Tue Dec 10, 2013 2:53 pm

Re: Find a specific word in the sentence

Post by Jellobus » Thu Aug 07, 2014 5:37 pm

Thank you all!!

I made it work with offset function. :mrgreen:

Louis

Post Reply