Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Adding tabs with GREP

Contributor ,
Jul 07, 2023 Jul 07, 2023

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

TOPICS
Bug , Feature request , How to , Scripting
1.3K
Translate
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 4 Correct answers

Community Expert , Jul 07, 2023 Jul 07, 2023

1) Find ~a

replace $0\t

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

Replace \t$0

3) Find 0018

Replace $0\t

Translate
Community Expert , Jul 07, 2023 Jul 07, 2023

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

Find: (?<=~a).

Replace: \t$0

Capture d’écran 2023-07-07 à 21.42.41.pngexpand image

 

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.

Translate
Community Expert , Jul 07, 2023 Jul 07, 2023

Find: 

(?<=\w)\d

 

Replace:

\t$0

Translate
Community Expert , Jul 12, 2023 Jul 12, 2023

Find: 

(?<=\*\*)\w

 

Replace:

\t$0

Translate
Community Expert ,
Jul 07, 2023 Jul 07, 2023

1) Find ~a

replace $0\t

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

Replace \t$0

3) Find 0018

Replace $0\t

Translate
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
Contributor ,
Jul 07, 2023 Jul 07, 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.

Translate
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
Community Expert ,
Jul 07, 2023 Jul 07, 2023

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

Find: (?<=~a).

Replace: \t$0

Capture d’écran 2023-07-07 à 21.42.41.pngexpand image

 

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.

Translate
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
Contributor ,
Jul 07, 2023 Jul 07, 2023

Yes, it does! Thanks so much! 🙂

Translate
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
Contributor ,
Jul 07, 2023 Jul 07, 2023

Can I also have a GREP that adds a tab betwwen a letter and number? Thx!

Translate
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
Community Expert ,
Jul 07, 2023 Jul 07, 2023

Find: 

(?<=\w)\d

 

Replace:

\t$0

Translate
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
Contributor ,
Jul 11, 2023 Jul 11, 2023

Thanks @jmlevy !

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



Translate
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
Community Expert ,
Jul 12, 2023 Jul 12, 2023

Find: 

(?<=\*\*)\w

 

Replace:

\t$0

Translate
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
Contributor ,
Jul 12, 2023 Jul 12, 2023

I just gave it a try, but no luck 😞 I'm attaching the INDD here, so you can take a look. Thx!

Translate
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
Community Expert ,
Jul 12, 2023 Jul 12, 2023

@Rogerio5C09 I tried it on your file and it works perfectly…

Before:

Capture d’écran 2023-07-12 à 15.57.34.pngexpand image

After:

Capture d’écran 2023-07-12 à 15.57.58.pngexpand image

Translate
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
Contributor ,
Jul 15, 2023 Jul 15, 2023

Oh, my bad, I realized I didn't copy the full expression when I tried it. It works perfectly indded 🙂

Can I have one that inserts a tab before uppercase text as well? Thx!

Translate
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
Contributor ,
Jul 15, 2023 Jul 15, 2023

I also need one that removes tabs at the end of text. And that should be all 🙂 Thanks again for

the help!

Translate
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
Community Expert ,
Jul 16, 2023 Jul 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.

Translate
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
Contributor ,
Jul 16, 2023 Jul 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/139159...

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!

Translate
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
Community Expert ,
Jul 16, 2023 Jul 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.

Translate
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
Contributor ,
Jul 16, 2023 Jul 16, 2023

Hey @jmlevy, sorry, let me explain the reason why I'm asking for it. When running Find/Change, I have to specify some formatting attributes as well to avoid involuntary changes accross other files. For the GREP you provided me for anchored objects, I added as attribute to find "Gotham Book" font in "Hyperlink" color, but I realized that some documents contain objects with a different font applied "Gotham Rounded". If I specify only the "Hyperlink" color attribute, the tab will appear in objects preceded by uppercase text where they are not supposed to be. Finding objects with font "Gotham Rounded" applied and change them to "Gotham Book" before running your Grep could be an option (Sorry, I just came up with this idea, so didn't try it yet hahaha). Anyways, If I had a Grep that adds a tab before uppercase text, I would set as

formatting attribute to find only font size and (paper) color. That would be the best option I think. Let me know your thoughts. Thx!

Translate
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
Community Expert ,
Jul 16, 2023 Jul 16, 2023

Well, to be honest, I don't understand why you don't run the query I provided to you for anchored objects, changing only the font attributes… Anyway, use the following query to find uppercase text and to add a tab before:

Find what: \<\u{2,}

Change to: \t$0

 

@Peter Kahrel wrote an excellent book about GREP (published by O'Reilly), but I don't know if it is still available.

Translate
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
Community Expert ,
Jul 16, 2023 Jul 16, 2023

Thanks for mentioning that book, @jmlevy -- there's in fact a new edition: 

https://creativepro.com/product/grep-in-indesign/

Translate
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
Contributor ,
Jul 19, 2023 Jul 19, 2023
LATEST

You are right from the start @jmlevy and changing the fonts attributes did the trick. I really appreciate all the help and thanks @Peter Kahrelfor sharing the link to the new edition book about GREP 🙂

Translate
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