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

Adding tabs with GREP

Contributor ,
Jul 07, 2023 Jul 07, 2023

Copy link to clipboard

Copied

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

Views

841

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

Votes

Translate

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

 

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.

Votes

Translate

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

Find: 

(?<=\w)\d

 

Replace:

\t$0

Votes

Translate

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

Find: 

(?<=\*\*)\w

 

Replace:

\t$0

Votes

Translate

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

Copy link to clipboard

Copied

1) Find ~a

replace $0\t

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

Replace \t$0

3) Find 0018

Replace $0\t

Votes

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

Copy link to clipboard

Copied

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.

Votes

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

Copy link to clipboard

Copied

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

 

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.

Votes

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

Copy link to clipboard

Copied

Yes, it does! Thanks so much! 🙂

Votes

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

Copy link to clipboard

Copied

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

Votes

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

Copy link to clipboard

Copied

Find: 

(?<=\w)\d

 

Replace:

\t$0

Votes

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

Copy link to clipboard

Copied

Thanks @jmlevy !

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



Votes

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

Copy link to clipboard

Copied

Find: 

(?<=\*\*)\w

 

Replace:

\t$0

Votes

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

Copy link to clipboard

Copied

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

Votes

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

Copy link to clipboard

Copied

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

Before:

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

After:

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

Votes

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

Copy link to clipboard

Copied

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!

Votes

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

Copy link to clipboard

Copied

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

the help!

Votes

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

Copy link to clipboard

Copied

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.

Votes

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

Copy link to clipboard

Copied

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!

Votes

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

Copy link to clipboard

Copied

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

Votes

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

Copy link to clipboard

Copied

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!

Votes

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

Copy link to clipboard

Copied

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.

Votes

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

Copy link to clipboard

Copied

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

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

Votes

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

Copy link to clipboard

Copied

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 🙂

Votes

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