Search and replace using wildcards found and replace with what was found?

Explorer ,
Mar 30, 2017 Mar 30, 2017

Copy link to clipboard

Copied

Hello, and thank you in advance for helping me if you can.  I have a 700+ page document and I need to search out ^9-^9 and have it replace it with the digits found but change the - to  –.  Is that possible?  I cannot request just the change from -  to – because some of them need to remain as they need changing only in certain circumstances.  There have often been times I need to search things like this (even with ^$) and have it use the wildcard feature to find but somehow request that it replace those wildcards with the same thing that was found.  Obviously I am not an InDesign guru, so I apologize for that and any of the novice language I have used..  Any advice would be greatly appreciated.
Best Wishes,

Maggie

Views

1.4K

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 , Mar 30, 2017 Mar 30, 2017

This is a job for GREP find and replace.  (The code below finds a hyphen between two numbers and replaces just the hyphen with an n-dash.)

find

(?<=\d)-(?=\d)

replace with

~=

Screenshot 2017-03-30 15.04.12.png

Likes

Translate

Translate
Adobe Community Professional ,
Mar 30, 2017 Mar 30, 2017

Copy link to clipboard

Copied

This is a job for GREP find and replace.  (The code below finds a hyphen between two numbers and replaces just the hyphen with an n-dash.)

find

(?<=\d)-(?=\d)

replace with

~=

Screenshot 2017-03-30 15.04.12.png

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
Explorer ,
Mar 31, 2017 Mar 31, 2017

Copy link to clipboard

Copied

SJRiegel,

Oh My!  THANK YOU SO MUCH!  It is truly appreciated.  That worked great, and it gave me the foundation so hopefully I can do some minor modifications on that idea for other applications.

Much appreciated,

Maggie

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
Adobe Community Professional ,
Mar 31, 2017 Mar 31, 2017

Copy link to clipboard

Copied

You're welcome, Maggie

GREP search and GREP styles are powerful tools - once you get to know them you will find all sorts of uses, and soon may be wondering what you ever did without them.

There are lots of online resources (including this forum) that can help you learn how to use them.

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 ,
Jun 12, 2022 Jun 12, 2022

Copy link to clipboard

Copied

I REALLY NEED YOUR HELP!!! i need to search - find and replace a tab after a 5 digit zipcode to the same number with a hard return after

Example:  12345^t to 12345^p 

 

There are lots of different zipcodes so the number will need to stay the same  - i just want to replace the tab with a return..

 

Any guidance would be SOOOO HELPFUL....

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
Adobe Community Professional ,
Jun 13, 2022 Jun 13, 2022

Copy link to clipboard

Copied

LATEST

Hi mclarkmd,

you do that with GREP Find/Change.

Look for a tab character \t that is preceded by a 5-digit number \d{5} that itself is fenced by a word begin and a word end \<\d{5}\>

 

Perfect for this kind of search is a positive look-behind like in this GREP pattern:

 

GREP Find:

(?<=\<\d{5}\>)\t

GREP Change:

\r

 

So you need not to replace a found piece of text with itself.

 

Regards,
Uwe Laubender
( Adobe Community Professional )

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