Skip to main content
Inspiring
March 30, 2017
Answered

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

  • March 30, 2017
  • 2 replies
  • 5069 views

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

    Correct answer SJRiegel

    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

    ~=

    2 replies

    Inspiring
    March 31, 2017

    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

    Legend
    March 31, 2017

    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.

    Participant
    June 12, 2022

    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....

    SJRiegelCorrect answer
    Legend
    March 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

    ~=