Solved

regExp for no space after period

Posted on 2002-06-24
2
208 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

929 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now