Javascript replace all "." except in one case...


I would like to check some text for occurences of periods where there is a character directly after it and add a space.  For example:  "This is an example.And this is another ex. for you." should become "This is an example.  And this is another ex. for you."  So, just the space inserted when there is another character (not for "ex.").

Not sure how to do this...

Thanks in advance!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Step 1. Replace all ". " occurrences with "."
Step 2. Replace all "." occurrences with ". "

Additional info:

You can use (free editor) Notepad++ in order to count the existing/replaced occurrences in case of a dot with several spaces after (".   ")
Repeat Step 1. until no more ". " exist
Apply Step 2. once, so you will obtain only ". " (dot followed by one single space)
RobOwner (Aidellio)Commented:
Or use regex
var mystring = "this is a test. Ex. This is not.on purpose";
mystring = mystring.replace(/\.[^ ]+/g,". ");

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
1CougarAuthor Commented:
I was looking for the javascript so @tagit :  thank you...that was what I was looking for.

RobOwner (Aidellio)Commented:
Sorry, got tht slightly wrong, should be:

replace(/\.([^ ]{1})/g,"\. $1");

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.