Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Grep repeat matches using negative lookahead and subexpressions

New Here ,
Aug 06, 2021 Aug 06, 2021

Copy link to clipboard

Copied

I have been tasked with making a bunch of documents made in an old clunky piece of software into Indesign files. The old software makes all line shifts full returns (some of which have extra spaces in front and behind them), and things that are supposed to be real returns are just double returns. Also it's intersperced with double spaces. It's a whole mess.

I wanna just be able to press "change all" in the story and have these things be largely fixed, so I came up with (|\s+)\r(|\s+)(?!\r)|\s{2,} to replace all my problems with a space.

It almost does everything I want it to do. Problem is, as soon as I add any other variables other than \r and (?!\r) it starts matcing repeating returns, which of course would remove the returns I actually need.

 

Skærmbillede 2021-08-06 104715.pngSkærmbillede 2021-08-06 104254.png

I've been trying a bunch of iterations where I don't include the plus, do different hierarchies and systematically removed and isolated several parts of it, and it always ends up matching repeating returns unless it's \r(?!\r).

 

Can someone tell me what I'm doing wrong?

TOPICS
How to

Views

35

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
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Aug 06, 2021 Aug 06, 2021
I think it might be easier to do it in steps. One way to deal with the double returns is to find them and replace with something else that would not otherwise occur, say [ZZZ]. then at the end you can find /[ZZZ/] and replace with a return.

Likes

Translate

Translate
Adobe Community Professional ,
Aug 06, 2021 Aug 06, 2021

Copy link to clipboard

Copied

I think it might be easier to do it in steps.

 

One way to deal with the double returns is to find them and replace with something else that would not otherwise occur, say [ZZZ]. then at the end you can find /[ZZZ/] and replace with a return.

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
community guidelines
New Here ,
Aug 16, 2021 Aug 16, 2021

Copy link to clipboard

Copied

LATEST

I ended up modifying the "findChangeByList" script using your trick.

Works like a charm!

Thanks

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
community guidelines