Below I have a sentance and desiredResult for the sentance. Using the pattern below I can snag the t T that needs to be changed to t, t but I don’t know where to go further.
var sentence = "Over the candidate behaves the patent Then the doctor.";
var desiredResult = "Over the candidate behaves the patent, then the doctor.";
var pattern = /[a-z]\s[A-Z]/g;
I want to a correct sentence by adding comma and a space before a capital other than ‘I’ if the preceding letter is lowercase.
Use
.replace()on your sentence and pass replacing function as second parameterAs for preserving uppercased
I, there are many ways, one of them:But there are more cases when it will fail, like:
His name is Joe.,WTF is an acronym for What a Terrible Failure.and many others.