I'm using this regex that was accepted as an answer in this question to split a paragraph into sentences, but the regex is splitting sentences at abbreviations/initials that contain/end with a period and at sentences that end with a quote. I'm unable to utilize negative lookbehinds as safari does not support them.
((?:[A-Z][a-z]\.|\w\.\w.|.)*?(?:[.!?]|$))(?:\s+|$)
The regex splits the following string:
"It was not a good translation because, according to Dr. Giles, "[I]t contains a great deal that Sun Tzŭ did not write, and very little indeed of what he did." The first translation into English was published in 1905 in Tokyo by Capt. E. F. Calthrop, R.F.A. However, this translation is"
into:
["It was not a good translation because, according to Dr. Giles, "[I]t contains a great deal that Sun Tzŭ did not write, and very little indeed of what he did." The first translation into English was published in 1905 in Tokyo by Capt.",
"E.","F.", "Calthrop, R.F.A.", "However, this translation is"]
Intended output is:
1: "It was not a good translation because, according to Dr. Giles, "[I]t contains a great deal that Sun Tzŭ did not write, and very little indeed of what he did.""
2: "The first translation into English was published in 1905 in Tokyo by Capt. E. F. Calthrop, R.F.A."
3: "However, this translation is"
I am stumped in figuring out how to fix this. This seems to be an edge case sentence and the regex works for most sentences but the punctuation here is throwing it off.
Any ideas on how I can fix this while also keeping it compatible with Safari?