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:
Hi, and thanks for the reply... These dont seem to work unfortunately, perhaps it helps if you look at the structure of the text below...
my index is currently formatted
tab #1 / text string / tab #2 / string of page numbers and commas / return
I am trying to assign a character style JUST to the text after the second tab...
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.
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.
Europe, Middle East and Africa