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.
matchText for punctuation (solved)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
matchText for punctuation (solved)
Last edited by monki on Mon Oct 12, 2015 2:23 am, edited 1 time in total.
-
- Livecode Opensource Backer
- Posts: 10100
- Joined: Fri Feb 19, 2010 10:17 am
Re: matchText for punctuation
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 [".","!","?"]
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 [".","!","?"]
Re: matchText for punctuation
Hi,
matchtext can be used with regular expressions. From the dictionary
Kind regards
Bernd
matchtext can be used with regular expressions. From the dictionary
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.matchText("Goodbye","bye")
matchText("Goodbye","^Good")
matchText(phoneNumber,"([0-9]+)-([0-9]+-[0-9]+)",areaCode,phone)
Code: Select all
put the number of codepoints of sentence 1 to 3 of field 1 after field 2
Bernd
Re: matchText for punctuation
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
thanks
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

thanks
Re: matchText for punctuation (solved)
Lucked into it.
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.

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,"[\. \! \?]")