Solved

regExp for no space after period

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
This article discusses how to create an extensible mechanism for linked drop downs.
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…

744 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

13 Experts available now in Live!

Get 1:1 Help Now