User Guide Cancel

Find and replace using GREP expressions and queries

  1. InDesign User Guide
  2. Get to know InDesign
    1. Introduction to InDesign
      1. What's New in InDesign
      2. System requirements
      3. Common questions
      4. Use Creative Cloud libraries
    2. Workspace
      1. Workspace basics
      2. Customize your workspace in InDesign
      3. Toolbox
      4. Set preferences
      5. Properties panel
      6. Touch workspace
      7. Default keyboard shortcuts
      8. Document recovery and undo
    3. Generative AI
      1. Text to Image
      2. Generative AI FAQ
  3. Create and layout documents
    1. Documents and pages
      1. Create documents
      2. Work with parent pages
      3. Work with document pages
      4. Set page size, margins, and bleed
      5. Work with files and templates
      6. Convert PDFs to InDesign files in InDesign (Beta)
      7. Create book files
      8. Add basic page numbering
      9. Number pages, chapters, and sections
      10. Convert QuarkXPress and PageMaker documents
      11. Share content
      12. Understand a basic managed-file workflow
      13. Save documents
    2. Grids
      1. Grids
      2. Format grids
    3. Layout aids
      1. Rulers
      2. Align and distribute objects using rulers
      3. Measure objects using the Measure tool
  4. Add content
    1. Text
      1. Add text to frames
      2. Threading text
      3. South-East Asian Scripts
      4. Arabic and Hebrew features in InDesign
      5. Create type on a path
      6. Bullets and numbering
      7. Glyphs and special characters
      8. Text composition
      9. Text variables
      10. Generate QR codes
      11. Edit text
      12. Align text
      13. Wrap text around objects
      14. Anchored objects
      15. Linked content
      16. Format paragraphs
      17. Format characters
    2. Typography
      1. Using fonts in InDesign
      2. Kerning and tracking
    3. Format text
      1. Format text
      2. Auto Style text
      3. Work with Style Packs
      4. Tabs and indents
    4. Review text
      1. Track and review changes
      2. Add editorial notes in InDesign
      3. Import PDF comments
    5. Spell check and language dictionaries
      1. Check spelling, autocorrect, and dynamic spelling
      2. Create, add, and manage dictionaries and words
      3. Change dictionary preferences
      4. Duden dictionary
    6. Add references
      1. Create a table of contents
      2. Footnotes
      3. Create an index
      4. Endnotes
      5. Captions
    7. Styles
      1. Paragraph and character styles
      2. Map, export, and manage styles
      3. Object styles
      4. Drop caps and nested styles
      5. Work with styles
      6. Leading
    8. Tables
      1. Format tables
      2. Create tables
      3. Table and Cell styles
      4. Select and edit tables
      5. Table strokes and fills
    9. Interactivity
      1. Hyperlinks
      2. Dynamic PDF documents
      3. Bookmarks
      4. Buttons
      5. Forms
      6. Animation
      7. Cross-references
      8. Structure PDFs
      9. Page transitions
      10. Movies and sounds
    10. Graphics
      1. Understand paths and shapes
      2. Draw with the Pencil tool
      3. Draw with the Pen tool
      4. Apply line (stroke) settings 
      5. Compound paths and shapes
      6. Edit paths
      7. Clipping paths
      8. Change corner appearance
      9. Frames and objects
      10. Align and distribute objects
      11. Linked and embedded graphics
      12. Integrate AEM assets
    11. Color and transparency
      1. Apply color
      2. Use colors from imported graphics
      3. Work with swatches
      4. Mix inks
      5. Tints
      6. Understand spot and process colors
      7. Blend colors
      8. Gradients
      9. Flatten transparent artwork
      10. Add transparency effects
  5. Find and replace
    1. Find and replace text
    2. Find and replace fonts
    3. Find and replace glyphs
    4. Find and replace using GREP expressions and queries
    5. Find and replace objects
    6. Find and replace colors
    7. Search options to find and replace
  6. Share
    1. Save and access cloud documents
    2. Organize, manage, and share cloud documents
    3. View and manage versions in cloud documents
    4. Common questions about InDesign cloud documents
    5. Share and collaborate        
    6. Share for Review
    7. Review a shared InDesign document
    8. Manage feedback 
  7. Publish
    1. Place, export, and publish
      1. Publish online
      2. Publish online dashboard
      3. Copy, insert graphics
      4. Export content for EPUB
      5. Adobe PDF options
      6. Export content to HTML
      7. Export to Adobe PDF
      8. Export to JPEG format
      9. Export HTML
      10. DPS and AEM Mobile overview
      11. Supported File Formats
      12. Export and import User Settings
    2. Printing
      1. Print booklets
      2. Printer's marks and bleeds
      3. Print documents
      4. Inks, separation, and screen frequency
      5. Overprinting
      6. Create PostScript and EPS files
      7. Preflight files before handoff
      8. Print thumbnails and oversized documents
      9. Prepare PDFs for service providers
      10. Prepare to print separations
  8. Extend InDesign
    1. Automation
      1. Data merge
      2. Plug-ins
      3. Capture extension in InDesign
      4. Scripting
  9. Troubleshooting
    1. Fixed issues
    2. Known issues
    3. Crash on launch
    4. Preference folder read-only issue
    5. Troubleshoot file issues
    6. Unable to export PDF
    7. InDesign document recovery

Learn to create GREP expressions and queries to find and replace alphanumeric strings and patterns.

With GREP expressions, you can find and replace alphanumeric strings and patterns in long or multiple open documents. You can also save frequently used search criteria as queries to save time.

Search using GREP expressions

  1. Select Edit > Find/Change, and select the GREP tab.

  2. In Find what, follow any of these options to construct a GREP expression:

  3. Type or paste the replacement text in Change to.

  4. Select Find Next.

    Select Change, Change All, or Change/Find to replace text and continue searching.

Construct a GREP expression

Open a document or multiple documents to find and replace text using GREP expressions.

Example: Find text within quotation marks and change the formatting

Follow these steps to find text within quotation marks and change its formatting:

  1. Type (“)(\w+)(“)in the Find what field.

    This expression contains three groupings, as indicated by the parentheses.

    The first and third groupings search for any quotation mark, and the second grouping searches for one or more word characters.

  2. In the Change to section, select Special characters for replace   icon > Found > Found Text.

    You can view $0 in the Change to field.

  3. Type any of the following in the Change to field to change the required grouping:

    $0 – to change all groupings

    $1 – to change the first grouping

    $2 – to change the second grouping and so on.

  4. Select Specify attributes to replace   icon in the Change Format section and the formatting.

  5. Select Find Next.

    Select Change, Change All, or Change/Find to replace text and continue searching.

Screenshot of the Find/Change panel with the example to find text within double quiotes

A. Find what B. Change to C. Find Format D. Change Format 

Additional GREP examples

Find criteria

GREP Expression

Example

Class of characters

[]

Type the following to find a, b, or c:

 

[abc]

Negative lookahead

(?!pattern)

Use this to avoid a certain pattern from your search. For example, to avoid finding InDesign CS versions from a list of InDesign versions, type:

 

InDesign (?!CS.*?)

Positive lookahead

(?=pattern)

Use this to find a certain pattern. For example, to find InDesign CS versions ONLY from a list of InDesign versions, type:

 

InDesign (?=CS.*?)

Case-insensitive on

(?i)

Use this to find text irrespective of the typing case. For example, if you want to find Apple in any case (apple, APPLE, and so on), type the following:

 

(?i)apple

Case-insensitive off

(?-i)

Use this to find Case-sensitive text. For example, if you want to find Apple ONLY (not apple, APPLE, and so on), type the following:

 

(?-i)apple

Find a character or word a certain number of times

{ }

Type any of the following to find the repeat number of a character or word:

 

b{3} - matches exactly 3 times

b(3,} - matches at least 3 or more times

b{3,}? - matches ONLY 3 times

b{2,3} - matches at least 2 times and not more than 3

Find and replace items using queries

query is a defined find-and-change operation. InDesign offers several preset queries for changing punctuation formats and other useful actions, such as changing telephone number formats. By saving a query you constructed, you can rerun it and share it with others.

To modify your text, objects, and glyphs, you have the option to either use an existing query or create a new one.

Search using queries

  1. Select Edit > Find/Change.

  2. Select a query from the Query list.

  3. Specify a range to search on the Search menu. You can’t save the search range with the query.

  4. Select Find Next.

    Select ChangeChange All, or Change/Find to replace text and continue searching.

After you select a search query in the Find/Change dialog, you can adjust the settings to fine-tune your search.

Example query: Phone number conversion

Follow along to convert the Phone number format with an in-built query:

  1. Select Edit > Find/Change.

  2. Select Phone Number Conversion (dot format) from the query list. You can see the following in the Find what field:

    \(?(\d\d\d)\)?[-. ]?(\d\d\d)[-. ]?(\d\d\d\d)

    Phone numbers in the United States can appear in various formats, such as 206-555-3982, (206) 555-3982, 206.555.3982, and 206 555 3982. This string looks for any of these variations.

  3. You can edit the grouping references in the Change to field to suit your needs. For example, you could use these expressions:

    206.555.3982 = $1.$2.$3

    206-555-3982 = $1-$2-$3

    (206) 555-3982 = ($1) $2-$3

    206 555 3982 = $1 $2 $3

Save queries

You can save a query in the Find/Change dialog to rerun it or share it with others. You can view the saved queries under the Query list of the Find/Change dialog.

  1. Select Edit > Find/Change.

  2. Select TextGREP, or a different tab to undertake the search you want.

  3. Select the Include Locked Layers and Locked Objects (Find Only)   icon, Include Locked Stories (Find Only)   icon, Include Footnotes   icon, etc., and you can save these along with the query. However, you can’t save the search range.

  4. Define the Find what and Change to fields. (See Metacharacters for searching and Search using GREP expressions.)

  5. Select the Save Query  icon and enter a name for the query.

Delete queries

  1. Select Edit > Find/Change.

  2. Select a query from the list and then select the Delete Query  icon.

Load queries

Customized queries are stored as XML files. The names of customized queries appear in the Query list in the Find/Change dialog.

macOS

Users\[username]\Library\Preferences\Adobe InDesign\[Version]\[Language]\Find-Change Queries\[query type]

Windows XP

Documents and Settings\[username]\Application Data\Adobe\InDesign\[Version]\[Language]\Find-Change Queries\[query type]

Windows Vista and Windows 7

Users\[username]\AppData\Roaming\Adobe\InDesign\[Version]\[Language]\Find-Change Queries\[query type]

More like this

Talk to us

We would love to hear from you. Share your thoughts with the Adobe InDesign Community

 Adobe

Get help faster and easier

New user?