Challenge Accepted
I am confused with the matched_list. You actually don't need to declare it again. Or simply declared it as matched_list = newList(); no inner element needed, as it will be replaced anyway.
And you don't even need the matched group, you only need to match the regex, no grouping needed.
Code: Select all
if(matches("The quick brown fox.", '[^.]+?\\.(?!\\.\\.)'))
{
a = true;// should be true for "jumped over the lazy dog."
}
else
{
a = false;// should be false for "The quick brown fox..."
}
When you need to match anything that is not dot, use [^.]+? this will match anything which is not dot.
Then the next \\. will match the last dot needed.
The (?!\\.\\.) is negative lookaround, will make sure if the last 3 character match with 3 dots (1 + 2), it will throw away the match.
2 dots at the end will also result in false, since it though it match partially, but it doesn't match all. You can check this in Automagic built-in regex tester. (just remember to change back the double backslash to single backslash)
This assume you don't have any dot in the middle of the sentence. However if you have it, you need to add another .+ to capture that and only stop at the last non dot capture.
the regex will be '.+[^.]+?\\.(?!\\.\\.)'