Solved

regExp for no space after period

Posted on 2002-06-24
2
212 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

734 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