Solved

regExp for no space after period

Posted on 2002-06-24
2
211 Views
Last Modified: 2010-05-18
I'm processing a text file that has frequent 'no space after a period' typos. Reading OReilly's JS Definitive I thought that I'd use:

\.\w

or possibly

\.\S

to find these instances but both apps I've tried this in (editPlus and Fund' Search & Replace are finding only instance of a . followed by a 'w' or 'S' respectively.

Both apps support reg expressions well enough that I'm sure the error is mine... So how do I find instances where a period is followed by anything except a space character?

thankx
--steve...
0
Comment
Question by:juststeve
  • 2
2 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 7104223
I tried this with Javascript, and it worked:


var str1 = "abc. def.ghi. 123";
var str2 = str1.replace(/\.\S/g,". ");
alert(str2);
0
 
LVL 33

Accepted Solution

by:
knightEknight earned 100 total points
ID: 7104336
... but there is a problem with more than one occurance ...

maybe you could forct the issue like this:

var str1 = "abcd. efg.hij klm.nop qrs.tuv wxyz.";
var str2 = str1.replace(/\.\s/g,".");  // first, force all dots to have no trailing space
var str3 = str2.replace(/\./g, ". ");  // then force all dots to have a space
alert(str3);
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question