Skip navigation
Currently Being Moderated

how to find text between TWO consecutive tabs and a return…

Feb 25, 2013 4:50 PM

Tags: #find #indesign #grep

Hello – - this great script finds all the text after a tab and before a return. Works like a dream in my paragraph style, thank you…


What I woudl love to find out is how to tune the script to find all the text between TWO consecutive tabs and a return…

Would be incredibly useful; trying to assign a character style to numbers in an index…

thanks for your time and assistance!



Original script found here: t-page-2#comment-550882

  • Currently Being Moderated
    Feb 25, 2013 4:53 PM   in reply to Matthew Appleton

    Try (?<=\t{2}).*?(?=\r) or (?<=\t\t).*?(?=\r)

    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 4:55 PM   in reply to Peter Spier

    That finds text after two tabs with nothing between them, which is how I interpret two consecutive tabs. If that's not waht you meant, you'll need to provide a clearer explanation.

    Mark as:
  • Currently Being Moderated
    Feb 25, 2013 5:12 PM   in reply to Matthew Appleton

    It's not a "script" but a GREP query. If your post tells us all of the conditions, then you don't need GREP at all. A nested character style will work just fine:



    If there's no forced line break, it'll continue applying the character style through the end of the paragraph. If you need it to continue through a forced line break, use an End Nested Style character instead.

    Mark as:
  • Currently Being Moderated
    Feb 26, 2013 9:54 AM   in reply to Matthew Appleton

    I think it's still worthwhile to figure out the GREP query that will work, but I always like to get the job done first, and then have fun stretching my brain to write the GREP query. Because I find writing GREP queries fun the same way that some people like to do crossword puzzles.


    One script that I'd suggest that you download and install, if you like stretching your cranium by writing GREP queries, is WhatTheGREP written by estimable forums regular [Jongware]. It does a fine job of expanding GREP queries into something approaching plain English.




    Anyhow, what you have here is this query


    .*?           (which means "find any group of zero or more characters, grab the shortest match")


    sandwiched in between a lookahead group and a lookbehind group. The first looks for a tab (that is \t) and the second looks for a hard return (that is \r). The advantage of lookahead and lookbehind is that you can look for stuff that is next to a tab without actually looking for the tab. So, all you have to do to turn your query into what you were originally asking for is to change the trailing \r into a \t




    which means "find the smallest amount of text possible between two tabs in a single paragraph."


    *     *     *     *     *    


    So, which is better, a nested style or a GREP query, or a GREP style? The reason I suggested a nested style is that I use 'em all the time when I have a project that has an index. A GREP find/replace query makes a permanent change to the index, but if I regenerate the index, I have to remember to re-run the find/replace query. I'd rather fob off the job of remembering stuff to a robot, and save my brain for more exciting tasks, like talking to my coworkers about social science research or Dwarf Fortress. So, it's going to be some kind of automatically applied style. Nested styles take less computing power to apply than do GREP styles. So I chronically advise people to use nested styles in this case, as it is the least taxing solution for your brain and for your computer.

    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