Skip to main content
Participating Frequently
November 1, 2017
Question

grep query to find full stop followed by 1 space

  • November 1, 2017
  • 5 replies
  • 4068 views

Hello

Could someone help me with grep queries please?

I want to find all full stops with a single space after it, and then replace it with a full stop and 2 spaces.

I want to find all full stops with 3 spaces after it, and then replace it with a full stop and 2 spaces.

Many thanks

This topic has been closed for replies.

5 replies

Participating Frequently
November 5, 2017

I did have trouble with a few of the suggestions, for example I have indented my page numbers using the indentation function yet this is picked up when I try to find spaces in a variety of ways so I am too nervous to do a change all!!

Thanks for all the help, I still have inconsistencies in my text and deciding whether to worry about it or not

winterm
Legend
November 5, 2017

If you could be a bit more specific, ideally - with screenshots, I bet decent solution is possible.

Participating Frequently
November 2, 2017

Well that wasn't the response I was expecting!  I am obviously very old school, I was taught 2 spaces after a full stop and never knew there was a whole discussion regarding it!

Thanks @nicholas@paperchefs.  I had tried to match in text and it wasn't recognising them properly so I will try again.  But now I think I will change everything to one space, many thanks for the input and information everyone!

Known Participant
November 2, 2017

Are you specifically looking for a Grep way to do this? Is easy enough to do in the Find/Change without Grep.

First delete all extra spaces replacing all "(2 spaces)" with "(1 space)" until there's nothing left to replace (that'll clear up all >=3 spaces as well). Then replace all ".(one space)" with ".(2 spaces)".

I frequently run a replace all "(2 spaces)" with "(1 space)" multiple times on documents to clean up any text I've pasted in.

Two spaces after period is incorrect IMHO, though.

Participating Frequently
November 3, 2017

Interestingly when I search for 2 spaces it returns 1 and 3 spaces as well

Obi-wan Kenobi
Legend
November 3, 2017

\.\K(\h)(\1{2})?(?!\1)

… will find 1 or 3 spaces following a full stop, but not 2, 4, 5, …

(^/)

Obi-wan Kenobi
Legend
November 1, 2017

Hi,

… Are you still interested if more than 3 spaces?!… 

(^/)

Jongware
Community Expert
Community Expert
November 1, 2017

.... I could help you do that, but I agree with Two spaces after a period: Why you should never, ever do it.