Anyone like regex challenges?
Posted: 04 Apr 2018 18:51
Ok, I'll admit I'm pretty lame at regex, so I'm probably missing something obvious (like look ahead/backward).
Trying to detect a single period ('.') at the end of the line. The difficulty I'm having is ensuring that the end of line doesn't end with '...'
I ended up resorting to this code:
Play with this solution here:
https://regex101.com/r/ALGVUA/1
Trying to detect a single period ('.') at the end of the line. The difficulty I'm having is ensuring that the end of line doesn't end with '...'
I ended up resorting to this code:
Code: Select all
match_list = newList(null, null, null, null, null);
if (matches("The quick brown fox...", '(.+?)(\\.)(\\.*)(\\s?$)',match_list) == true and match_list[3] == "")
{
// should be true for "jumped over the lazy dog."
}
else
{
// should be false for "The quick brown fox..."
}
https://regex101.com/r/ALGVUA/1