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

GREP to remove numbers

Enthusiast ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

I have a Word document with a numbered list imported into InDesign and want to remove the numbers, replace them with nothing, and make them into an InDesign numbered list using the numbered list feature in InDesign.

Each item in the list starts with a number (Some are double digits), followed by a space, then a period, which is followed by a tab stop. Like this:

I've tried lots of variations in GREP and can't seem to come up with a solution. Would appreciate any suggestions. Thanks.

TOPICS
Scripting

Views

3.4K

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

Guide , Nov 02, 2018 Nov 02, 2018

1.

Play:  ^[0-9]+\.\h*\t

a.

A.

Play: ^(?i)[a-z]+\.\h*\t

•

Play: ^\H\h*\t

Votes

Translate

Translate
Guide ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

^\d+\.\h+

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
Enthusiast ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

This works great -- thank you so much! It even works well with lists from MS Word when there is no space between the period and the tab.

However, I just noticed that there are some sub-lists with alphabetic characters.

I tried inserting wildcards Any Character and Any Letter into the GREP, but that doesn't do it.

Can the GREP find both digits and alpha characters in a list?

Can the GREP also remove bullets in a bulleted list from MS Word?

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
Guide ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

At your own risks:

^\H+\.?\h*\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
Enthusiast ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

I see what you mean. The GREP deleted a paragraph that ended in a colon, and that I needed to keep.

I think it would be safer to use three separate GREPs -- one for deleting the numbers in a numbered list, one for deleting alpha characters in an alphabetical list, and one for deleting bullets in a bulleted list.

I wish I could do this on my own, but I'm not getting it.

What would two separate GREPs look like for deleting alpha character dot tab, and for deleting bullet tab in an imported Word document?

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
Guide ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

Try this:

^(\w+\.|\H)\h*\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
Enthusiast ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

You're right -- That works great for everything!

Still, it would work better for my particular documents to do 3 separate the searches. That way I can put the paragraph style into the change box -- separate paragraph styles for numbered list, alpha list, and bulleted list.

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
Guide ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

1.

Play:  ^[0-9]+\.\h*\t

a.

A.

Play: ^(?i)[a-z]+\.\h*\t

•

Play: ^\H\h*\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
Enthusiast ,
Nov 02, 2018 Nov 02, 2018

Copy link to clipboard

Copied

All three are working like a charm. Thank you so much! I'm sorry to have imposed on your time and talent.

I made a note of the GREPs so that I can refer to them and hopefully won't have to ask again.

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
Enthusiast ,
Nov 04, 2018 Nov 04, 2018

Copy link to clipboard

Copied

I'm having trouble with what to put into the Change To box. What should I put into the Change To box so that the original [digit period space] is removed and the paragraph style is applied?

For example, if I am removing a [digit period space] and replacing with a paragraph style, like the setting below, the paragraph style is applied but the original [digit period space] are not removed.

If I use these settings, the paragraph style is applied but the text "$1" is added at the beginning of each item in the numbered list.

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

You always have to give inDesign something for replacements, it can't use insertionPoints for replacement. Try this:

Find: ^[0-9]+\.\h*\t(.)

Change to: $1

So you replace the character after \t with itself.

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
Enthusiast ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Thank you so much for this, Peter -- That's amazing!!! I am so excited that it works exactly as I need it to remove numbers and replace with a paragraph style all in one fell swoop!

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
Guide ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

Just for comment:

This kind of Grep code has already been given in your other thread, post 2:

Find/Change Not Finding Manual Bullets from Word File

… Maybe time to begin to learn 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
Enthusiast ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

I'd love to learn GREP so that I could do this myself. Do you have any resources to recommend that are easy to understand for a inexperienced novice and non-programmer?

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
Guide ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

A question for Peter! …

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 ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

CreativePro (aka InDesignSecrets) are about to re-publish my GREP in InDesign title (the one that was published by O'Reilly before). I'll keep you posted.

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
Enthusiast ,
Nov 05, 2018 Nov 05, 2018

Copy link to clipboard

Copied

I'll look forward to your book.

You and Michel have been a tremendous help to me in getting my project finished. I thank you both profusely.

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 ,
Nov 08, 2018 Nov 08, 2018

Copy link to clipboard

Copied

Jay -- Hot off the press, so to speak:

https://sites.fastspring.com/publishingsecrets/product/GREP3

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
Advocate ,
Nov 09, 2018 Nov 09, 2018

Copy link to clipboard

Copied

Just to shine some light on the replacements:

If you put something in brackets, you then can access that part by $1, $2, $n.

Just as example:

So Search for (\d+) x (\d+)

and replace with

$2 x $1

for 123 x 456 to 456 x 123.

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 ,
Nov 11, 2018 Nov 11, 2018

Copy link to clipboard

Copied

Hi Peter Kahrel​

your offer means 10,24€ but I have to pay 12,22€

Something is wrong?

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 ,
Nov 11, 2018 Nov 11, 2018

Copy link to clipboard

Copied

Well, it's not my offer. . . I've no idea if anything is wrong, I've nothing to do with the pricing. maybe raise it in a comment in the announcement here:

https://indesignsecrets.com/now-available-grep-in-indesign-3rd-edition.php

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
Community Expert ,
Nov 13, 2018 Nov 13, 2018

Copy link to clipboard

Copied

A short update:

The reason for the difference was: The price shown is without any VAT or tax.

But meantime they changed the payment process. Now you can see (while paying) the price, the VAT and the final price.

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 ,
Nov 13, 2018 Nov 13, 2018

Copy link to clipboard

Copied

LATEST

Thanks for the update.

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