I have a rather confusing regex expression to match words and punctuation within a sentence:
var sentence = "Exclamation! Question? Full stop. Ellipsis...";
var words = sentence.toLowerCase().match(/\w+(?:'\w+)*|(?<![!?.])[!?.]/g);
console.log(words);
In Chrome, this outputs:
[ "exclamation", "!", "question", "?", "full", "stop", ".", "ellipsis", "." ]
In Firefox, this expression causes an error which seems to be due to the reverse lookahead.
I was wondering if it would be possible to rewrite this expression in a way which will work in Firefox, or if there is any other way in which I could accomplish this?