Skip navigation
1John5vs7
Currently Being Moderated

Excluding a character from "Change to" box that is in "Find what" box in GREP search

Jan 13, 2014 10:21 AM

Tags: #search #grep #exclusion #t #d #change_to #grep_search #character_exclusion #exclude_character

Hello all! I am a first time poster but have been lurking around the forums for a few months. I'm trying to produce an InDesign document for a book I'm putting out, and there is a section where I have the following text:

 

|  TAB  |1.|  TAB  |Lorem ipsum dolor etc.

 

The text doesn't literally say tab, I jsut wanted to highlight that there is a tab of white-space on either side of the number for the line. This occurs numerous times in numerous chapters in the endnotes section. I want to remove the tabs so that the result is:

 

1. Lorem ipsum dolor etc

2. Lorem ipsum dolor etc

3. etc etc

 

I have identified that the way to find these sections is to use the GREP search function with \t\d+.\t. The + is there because the numbers go into the double digits in most chapters for the references. However, I do not want to remove the numbers, just the tabs. Is there any way to add an exclude feature to the "Change to" window of the search function? I've tried just leaving it as \d., but that literally changes the text to

 

\d. Lorem ipsum dolor etc

 

That's not good. I'm trying to avoid having to do all of this by hand, and of course by the time I get a resolution I'll probably have been better off doing it manually, but I'm looking toward the future and trying to ascertain the best way of streamlining such a process short of not having that kind of format in the first place when receiving the file from my employer

 

Many thanks for your advice,

 

David

 
Replies
  • Currently Being Moderated
    Jan 13, 2014 10:40 AM   in reply to 1John5vs7

    First, let's establish that these are not part of an automatically formatted numbered list using the bullets and numbering options in the paragraph style (though they probably should be).

     

    If you don't want to make them part of a numbered list, you should be able to find (^\t)(\d+)(\t) and change to $2[space character of your choice]

     

    That said, I would make them the list and define it in a paragraph style, then find ^\s+\d+\s+ and replce with nothing, but change the change format to the correct paragraph style where the numbers and the spacer are defined. The advantage to this is that you can then rearrange, add or delete paragraphs in the list and the numbering will update automatically.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2014 10:57 AM   in reply to 1John5vs7

    Just so you understand, [space character of your choice] is just my way of saying put something in this spot after the $2 (without the []) to use as a separator. It can be a regular space, a fixed width space, or a tab (but you'll want to set the tab in the paragraph style) so the text always starts at the same position. You could even set a left indent equal to the tab position, and a negative first line indent if you need the numbers to hang to the left of the paragraphs when there is more than one line.

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 13, 2014 11:36 AM   in reply to 1John5vs7

    Sorry, my fault entirely. I left out the period in the search query.

     

    The correct query is (^\t+)(\d+\.)(\t+) if you are looking for "one or more" tabs on either side. The . in GREP is a wildcard for any character when used outside a class, so it would need to be "escaped" as \. .

     

    If you don't know what the whitespace situation is, you can use (^\s+)([\d.]+)(\s+) which will find all whitespaces, not just tabs. The [\d.] class is any digit and the period (inside the class it's literal), and it would find any combination of digits and periods, like 1.2.33  in case your numbering runs that way.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points