Copy link to clipboard
Copied
Hi all, sorry for what I am sure is but one of many GREP questions.
Right now I have end notes that, in the start of each paragraph, begin:
1.[space]
And I'd like to change them all to
1.[tab]
This must happen only at the beginning of each paragraph and that's kind of the hard part since the above construction takes place in various places in each paragraph.
Any help would be appreciated.
In Find/Change dialog GREP tab:
Find what: ^\d+\.\K\h
Change to: \t
Copy link to clipboard
Copied
In Find/Change dialog GREP tab:
Find what: ^\d+\.\K\h
Change to: \t
Copy link to clipboard
Copied
That ought to work – but, no explanation?
Copy link to clipboard
Copied
Ha! Couldn’t it be a part of OP’s homework?
Here’s a decent start: find and install a bit outdated but still excellent script What the GREP by Jongware (I bet you know that guy ), and you’ll find most explanations for this and many other codes. Well, except some relatively new…
Copy link to clipboard
Copied
I have updated WhatTheGREP to include the codes \v, \h, and \K.
New version is downloadable at Indesign GREP Help ​ again -- I did not change the download zip name so older references to it will still work.
Copy link to clipboard
Copied
Knowing full well that you know the explanation, I'm going to give it a shot because I'm working on understanding GREP and I know either of you can advise me if I get it wrong.
Here's my try at the explanation of winterm's expression, [Jongware]:
Find one or more digits at the beginning of a paragraph
^\d+
Followed by a period
\.
This one is harder for me. This is an advanced/recent version of the positive look-behind found in the widgets menu in the F/C dialog box—meaning that the earlier items must be present
\K
followed by a horizontal space
\h
and because the \K, this places the focus on just the space and replaces it with a tab.
Critique, please!
~Barb
Copy link to clipboard
Copied
Absolutely
Copy link to clipboard
Copied
Absolutely what? That you both can help or that I got it right?
If it's I got it right I am so happy because I didn't look anything up!
~Barb
Copy link to clipboard
Copied
Sure, YOU GOT IT RIGHT
Ah, and this was a simple, basic case, so a lot of people here in this forum could help easily with this.
Not to mention such a script/grep monsters as
Copy link to clipboard
Copied
Yay! I'm learning!
Last comment. If I had seen this question first I would have offered:
FW: ^(\d+)\.\s
CT: $1\t
That works too, right? Though it strikes me as a beginner's approach, as opposed to your expression.
~Barb
P.S. This is one of the reasons that I love helping out on the forums. Watching GREP-monsters like you two inspired me to start learning GREP. My newly-acquired knowledge has cut hours off of my layout time in both InDesign and FrameMaker.
Copy link to clipboard
Copied
Why not, with a minor correction:
^(\d+\.)\s
otherwise you’ll loose a dot.
\s includes vertical spaces, too, and this may lead to unwanted results sometimes. \h is just safer here.
Another 'good practice': I usually avoid 1) using groups in GREP if I can, and 2) replace anything to itself (again, when there’s no real need to).
***
OT: I'm not even close, believe me.
Copy link to clipboard
Copied
Yes, I did lose the dot. Guess I would have realized that eventually, in a real job.
Thank you for all the feedback. Baby steps.
~Barb
Copy link to clipboard
Copied
Worked like magic. THANK YOU!
Copy link to clipboard
Copied
You can think about \K as a some kind of a Positive Lookbehind, and \h stands for any horizontal whitespace.