matchText for punctuation (solved)

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
monki
Posts: 59
Joined: Tue Dec 13, 2011 10:56 pm

matchText for punctuation (solved)

Post by monki » Sun Oct 11, 2015 3:23 pm

I'm trying to matchText for the end of sentences, something like "*/[.!?]/" or "*[\.\!\?]" but I can't find a pattern that to match the punctuation that Livecode likes. Any ideas?

Thanks.
Last edited by monki on Mon Oct 12, 2015 2:23 am, edited 1 time in total.

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

Re: matchText for punctuation

Post by richmond62 » Sun Oct 11, 2015 8:25 pm

I'm not sure if I entirely understand what you are trying to do, but I do see from the Documentation that the way matchText
is explained there is different from your examples:

matchText ["Goodbye","Get Lost"]

I could see no sign of those backslashes.

So, I wonder if you might be better with something like matchText [".","!","?"]

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: matchText for punctuation

Post by bn » Sun Oct 11, 2015 9:35 pm

Hi,

matchtext can be used with regular expressions. From the dictionary
matchText("Goodbye","bye")
matchText("Goodbye","^Good")
matchText(phoneNumber,"([0-9]+)-([0-9]+-[0-9]+)",areaCode,phone)
But as of LC 7 their is a "Sentence" keyword, maybe that helps? Once you parse for sentences you could do the usual chunk operations on them.

Code: Select all

put the number of codepoints of sentence 1 to 3 of field 1 after field 2
Kind regards

Bernd

monki
Posts: 59
Joined: Tue Dec 13, 2011 10:56 pm

Re: matchText for punctuation

Post by monki » Mon Oct 12, 2015 1:41 am

Yeah, I realize I didn't give enough information in my original post. A bit of frustration and lack of sleep, I guess.

I'm trying to return a boolean on a word, "true" if the word contains ".,?,!", which may, or may not be at the end of the word. So the pattern should be
"some amount of characters","a single sentence closing punctuation mark","maybe a quote, maybe not"

I think the main problem I'm having is that everything I need to match against is a special character. And, my attempts to "escape" them have only generated errors. In an online regular expression tester "*(\.|\?) selects all the "." marks on the page. But anything similar in livecode just tosses up a debugger. I feel that "*(\.|\?|\!)*" should match the words I'm trying to identify, but at this point, it's just a guessing game of unhelpful errors. I'm afraid that I don't understand this part well enough see where I'm going wrong. But that's why we try new things 8)

thanks

monki
Posts: 59
Joined: Tue Dec 13, 2011 10:56 pm

Re: matchText for punctuation (solved)

Post by monki » Mon Oct 12, 2015 2:27 am

Lucked into it. :D Some quote about monkeys and typewriters seems appropriate.

Here it is if anyone else has a similar problem. Returns true for sentence closing punctuation marks, including those inside quotes.

Code: Select all

matchText(tWord,"[\. \! \?]")

Post Reply