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
1) Find ~a
replace $0\t
2) Find \b\d{1,2}\b
Replace \t$0
3) Find 0018
Replace $0\t
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.
Find:
(?<=\w)\d
Replace:
\t$0
Find:
(?<=\*\*)\w
Replace:
\t$0
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
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.
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
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.
Copy link to clipboard
Copied
Yes, it does! Thanks so much! 🙂
Copy link to clipboard
Copied
Can I also have a GREP that adds a tab betwwen a letter and number? Thx!
Copy link to clipboard
Copied
Find:
(?<=\w)\d
Replace:
\t$0
Copy link to clipboard
Copied
Thanks @jmlevy !
I also need one that finds 2 asterisks (**) followed by a word (e.g: "**Population")
Copy link to clipboard
Copied
Find:
(?<=\*\*)\w
Replace:
\t$0
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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!
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!
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.
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
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!
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.
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!
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.
Copy link to clipboard
Copied
Thanks for mentioning that book, @jmlevy -- there's in fact a new edition:
Copy link to clipboard
Copied
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 🙂