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

GREP search help: digit+space changed to digit+tab

Community Beginner ,
Dec 09, 2018 Dec 09, 2018

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.

Views

908

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 1 Correct answer

Mentor , Dec 09, 2018 Dec 09, 2018

In Find/Change dialog GREP tab:

Find what: ^\d+\.\K\h

Change to: \t

Votes

Translate

Translate
Mentor ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

In Find/Change dialog GREP tab:

Find what: ^\d+\.\K\h

Change to: \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
Community Expert ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

That ought to work – but, no explanation? 

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
Mentor ,
Dec 09, 2018 Dec 09, 2018

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…

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 ,
Dec 14, 2018 Dec 14, 2018

Copy link to clipboard

Copied

LATEST

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.

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 ,
Dec 09, 2018 Dec 09, 2018

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

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
Mentor ,
Dec 09, 2018 Dec 09, 2018

Copy link to clipboard

Copied

Absolutely

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 ,
Dec 09, 2018 Dec 09, 2018

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

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
Mentor ,
Dec 09, 2018 Dec 09, 2018

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 …

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 ,
Dec 09, 2018 Dec 09, 2018

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.

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
Mentor ,
Dec 09, 2018 Dec 09, 2018

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. is above stratosphere.

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 ,
Dec 09, 2018 Dec 09, 2018

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

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 Beginner ,
Dec 11, 2018 Dec 11, 2018

Copy link to clipboard

Copied

Worked like magic. THANK YOU!

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
Mentor ,
Dec 09, 2018 Dec 09, 2018

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.

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