Using GREP to find the end of a paragraph and ignoring forced break lines

Explorer ,
Jan 06, 2021

Copy link to clipboard

Copied

Hi everyone and happy new year,

 

I'm stuck with a grep problem I thought would be easy, but its not, at least for me.

I need to do a grep search to every coma "," at the end of a paragraph and replace it with nothing. At first I was using "$" at the end of the paragraph because it's supposed to mean "end of paragraph", but unfortunately, it's also searching the "," at the end of a forced break line inside a paragraph.

 

The the GREP is basicaly:

,$

 

 

 

I tried this one too:

,(?:[\n])$

(?:[\n]) is supposed to ignore \n which is a forced break line I thought.

 

 

So, have you any idea on how I can ignore the forced break lines in a paragraph?

 

Thanks everyone,

Nicolas

TOPICS
How to, Scripting

Views

46

Likes

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

Using GREP to find the end of a paragraph and ignoring forced break lines

Explorer ,
Jan 06, 2021

Copy link to clipboard

Copied

Hi everyone and happy new year,

 

I'm stuck with a grep problem I thought would be easy, but its not, at least for me.

I need to do a grep search to every coma "," at the end of a paragraph and replace it with nothing. At first I was using "$" at the end of the paragraph because it's supposed to mean "end of paragraph", but unfortunately, it's also searching the "," at the end of a forced break line inside a paragraph.

 

The the GREP is basicaly:

,$

 

 

 

I tried this one too:

,(?:[\n])$

(?:[\n]) is supposed to ignore \n which is a forced break line I thought.

 

 

So, have you any idea on how I can ignore the forced break lines in a paragraph?

 

Thanks everyone,

Nicolas

TOPICS
How to, Scripting

Views

47

Likes

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
Jan 06, 2021 0
Advocate ,
Jan 06, 2021

Copy link to clipboard

Copied

Use this:

,(?=~b)

Likes

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
Reply
Loading...
Jan 06, 2021 1
Advocate ,
Jan 06, 2021

Copy link to clipboard

Copied

or this:

,(?!\n)$

Likes

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
Reply
Loading...
Jan 06, 2021 0
Explorer ,
Jan 06, 2021

Copy link to clipboard

Copied

Thanks a lot Jean-Claude, both solutions work perfectly!

 

If I understand, the first one search for a "coma" and after it the search must be followed by a paragraph mark, and the second one should be the correct syntax to find any coma at the end of a paragraph excluding any forced break line.

 

Thanks again! 🙂

Likes

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
Reply
Loading...
Jan 06, 2021 1