From another question, I have this expression to match words in a sentence:
var sentence = "Exclamation! Question? Full stop. Ellipsis...";
console.log(sentence.toLowerCase().match(/\w+(?:'\w+)*/g));
It works perfectly. However, now I am looking for a way to match exclamation marks, question marks, and full stops separately. The result should look like this:
[
"exclamation",
"!",
"question",
"?",
"full",
"stop",
".",
"ellipsis",
"."
]
Only matching one dot from the ellipsis, not all three dots separately.
Any help would be greatly appreciated!