Trying to break a string into sentences using regex can be tricky. Unfortunately, the regex used in this example:
var text = "Mr. Smith bought cheapsite.com for 1.5 million dollars, i.e. he paid a lot for it. Did he mind? Adam Jones Jr. thinks he didn't. In any case, this isn't true... Well, with a probability of .9 it isn't."
// break string up in to sentences based on punctation and quotation marks
var tokens = text.match(/(?<=\s+|^)[\"\'\‘\“\'\"\[\(\{\⟨](.*?[.?!])(\s[.?!])*[\"\'\’\”\'\"\]\)\}\⟩](?=\s+|$)|(?<=\s+|^)\S(.*?[.?!])(\s[.?!])*(?=\s+|$)/g);
does not work on IOS Safari due to unsupported
lookbehind assertions ((?<= ) and (?<! ))
. Are there other options I can use that are compatible with iOS Safari? It would be great if the new regex could also avoid other compatibility issues as mentioned in this link: (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#assertions)
ECMAScript (ECMA-262)
The definition of 'RegExp' in that specification.