Skip to main content
Inspiring
July 7, 2023
Answered

Adding tabs with GREP

  • July 7, 2023
  • 2 replies
  • 2204 views

Hi everyone,

I'm working on several documents that cotain missing tabs. I'm looking for a way to add them back and I belive we could do it with Find/Change GREP.

Fow now, I need 3 GREPs that adds:
1) a tab after an anchored object
2) a tab before a single number (and for 2 numbers please)
3) a tab after "0018"

Thanks in advance for your help!
Rog

This topic has been closed for replies.
Correct answer jmlevy

Thanks @jmlevy !

I also need one that finds 2 asterisks (**) followed by a word (e.g: "**Population")




Find: 

(?<=\*\*)\w

 

Replace:

\t$0

2 replies

Peter Kahrel
Community Expert
Community Expert
July 16, 2023

Delete tabs at the end of a text:

 

Find what: \t+\Z

Change to: <Leave empty>

 

If you meant 'at the end of each paragraph', then you'd use

 

Find what: \t+$

Change to: <Leave empty>

 

\Z is the end of a story, $ is the end of a paragraph. It's worth your while familiarising yourself with with the basics of GREP.

 

P.

Inspiring
July 16, 2023

Thanks @Peter Kahrel! I'll give it try and let you know if anything 🙂 About adding a tab before uppercase text, I'm afraid the GREP expression "(?=\u\u+)" you shared on this post 

https://community.adobe.com/t5/indesign-discussions/inserting-a-tab-before-formatted-text/m-p/13915981#M532641

doesn't work with the test files that I have - find them attached in my previous comments. Could you or @jmlevy please check? Maybe another Grep would do the trick? Thx!

jmlevy
Community Expert
Community Expert
July 16, 2023

@Rogerio5C09 one thing is not clear for me: in the test file you have provided, all the uppercase texts are preceded by an anchored object, and you already have the solution.

jmlevy
Community Expert
Community Expert
July 7, 2023

1) Find ~a

replace $0\t

2) Find \b\d{1,2}\b

Replace \t$0

3) Find 0018

Replace $0\t

Inspiring
July 7, 2023

Hi @jmlevy, many thanks for the quick response! 🙂

1) works only if I manually find and change each anchored object. When I click on "Change All", it replaces the objects with tab. I attached and indd here, so you can take a look.

2) and 3) worked just as expected.

jmlevy
Community Expert
Community Expert
July 7, 2023

I have absolutely no idea why this happens. Anyway, I found a workaround. Try this:

Find: (?<=~a).

Replace: \t$0

 

This query searches for any character preceded by an anchored object and replaces it by a tab, followed by what has been found. I tested it on your test file and it works.