• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

GREP assistance? Punctuation without following space that is WWW proof

Engaged ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

I'm trying to write a GREP that will check for commas and full stops that don't have whitepspace after them.

 

It would look for the two issues in this paragraph.Missing spaces after the fullstop,and also the comma.

 

The problem is that it also finds all the URLS such as:

 

www dot bob dot com (<--- had to write it like this or the forum didn't like it!).

 

I've used many variations around this sort of idea:

([\.,])[^ ].*(?!\.com)

 

... but it's just greedy and grabs the whole URL rather than ignoring it.

 

I should add that my documents contain an annoying number of URL suffixes, such as .co.uk, .com, .au!

TOPICS
Scripting

Views

168

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Aug 24, 2021 Aug 24, 2021

At your own risks! … [just tested on a simplistic sample] =D

 

(?!(\h|\H*\.(com|(co\.)?uk|au)\>|$))[.,](?=\S)

 

[code corrected]

 

(^/)  The Jedi

Votes

Translate

Translate
Community Expert ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

I don't believe this is possible as a single-step process. I would approach by first finding urls and adding some sort of tag to them that won't otherwise appear in your text swo as to protect them from being found in the next step, then search for your un-spaced punctuation and fix it, then find and remove the tags you added in the first step.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

Hey Peter,  thanks for answering. That'll be why I've been struggling with it then! Is the searching for results NOT tagged with something reliant on the use of conditions?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

At your own risks! … [just tested on a simplistic sample] =D

 

(?!(\h|\H*\.(com|(co\.)?uk|au)\>|$))[.,](?=\S)

 

[code corrected]

 

(^/)  The Jedi

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

LATEST

Wow this is massively improved over what I'm using at the moment. Thanks! I'm going to studay this really carefully and get my head around it. Thanks FRIdNGE!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines