Copy link to clipboard
Copied
I frequently create forms where I'll use a tab with the underline for the leader, e.g., Name_________________ Age___________, etc.
I like the line to be thinner than the text, say the text is 10pt I'll change the line to 8pt. I can do a Find/Change to change the Tab character to a smaller size, but that changes every tab whether it has a leader or not. I can't find a way to "Find every tab with a leader that's the underline and reduce the point size".
Any suggestions appreciated.
Geoff
Copy link to clipboard
Copied
Hi,
To find all occurences ==> array
To iterate through array elements checking a condition
To change only the chosen one
Writing a code - which line stopped you?
Jarek
Copy link to clipboard
Copied
Writing a code - which line stopped you?
Thanks, no I was trying through GREP Find/Change.
Copy link to clipboard
Copied
Hi,
No solution in UI, I am afraid.
Writing a javascript code you are able to split find...change into steps and proccess only chosen one.
By the way: What unwanted result is if your tabulator is applied with smaller pointSize and there no leader present?
Jarek
Copy link to clipboard
Copied
No solution in UI, I am afraid.
Bummer. I guess no harm to reduce pt size of non-leader tab, just wanted to keep it "clean" and thought maybe a solution with GREP.
Copy link to clipboard
Copied
Hm, maybe I did not understand the question …
these are normally InDesign-basics: Apply the underline not to the tab in the tab panel, instead apply a characterStyle with underline-option = true to the tab itself. This can be one by a grepstyle.
Copy link to clipboard
Copied
Hi Kai,
Many ways to apply underline but the goal is not to every tab ==> only to specific ones.
Jarek
Copy link to clipboard
Copied
Hi Jarek,
hm again. I don’t see the problem here 😉
The scope of the search can be reduced by using different paraStyles. Even with one style, it should be possible to find only those tabs, that are preceded by special words.
To reduce the scope a bit further, we could use a lookbehind with the different words. To avoid the limitations of a lookbehind, we could also use \K.
Kai
Copy link to clipboard
Copied
Hi Kai, cool use of \K!
Copy link to clipboard
Copied
Hi Kai,
I dont see a problem as well if we can find a rule other than OP described.
For now only one rule is ==> target tab has a leader.
Jarek
Copy link to clipboard
Copied
Kai,
I don't see a lookbehind in your screenshot.
And what is \K? Never seen that one.
Peter
Copy link to clipboard
Copied
Hi Peter, That is the lookbehind! 😉
Copy link to clipboard
Copied
Peter,
why?
the first screen shows ((?<=Name)|(?<=Age))\t. Because of the length-limitation it could not be written as (?<=Name|Age)\t
The second one shows a new metacharacter, that was found months ago and mentioned on the facebook-grep-list (don’t know who discovered it first).
You find more informations here: Keep The Text Matched So Far out of The Overall Regex Match
Copy link to clipboard
Copied
Sorry, Kai, I didn't look closely enough, but I see the lookbehind now.
As to the \K operator, I didn't know that one, will read up, thanks for mentioning it and for the link
> That is the lookbehind!
How do you mean, Hooded One -- \K is the lookbehind?
P.
Copy link to clipboard
Copied
Essentially it 'forgets' everything that matched so far, so it's kind of a look-behind. There may be a more subtle difference. Maybe this is the solution for the elusive "cannot use variable length look-behinds" problems that pestered us in the past!
\K must be "New! Now in InDesign CC 2014!"; and possibly earlier, but not as early as CS4. For CS4, I checked all of the regular, and most of the more obscure, GREP codes when I wrote whatthegrep in 2010. For "\K", I added the remark
[ 'K', "Reset start location of $0" ], // NOT supported; literal 'K'
where the 'literal' means I found GREP searches for just a 'K', even if you feed it '\K'. I checked again just now (you never know! it could have been in an update!) and the exact same string still does not work in CS4, and it does in CC'14. It even works in a GREP style, so no Find/Change needed!
Copy link to clipboard
Copied
(Veering happily off-topic)
This also works:
\R -- "Any Line End character sequence" (finds Return, Soft Line Break, New Page)
The following still do not (but I may have not constructed my search correctly):
\y, \Y, \m, \M -- something to do with words, forgot to note what they should do...
\10..\99 -- back references past \9 -- these look for \1, followed by '0' etc.
\G -- "start of match attempt" (I may have used it wrong)
\uXXXX, still not
\p{IsL}, \p{IsLu}, \p{IsLetter}, \p{IsLowercaseLetter}, \p{Arabic}, \p{IsArabic} and the rest of the more advanced named Unicode properties
[a-z-[fgh]] -- character class subtraction
\p{IsAlpha} -- "Is" forms of POSIX classes (without "Is" it works)
So there has been some update of the GREP library, but unfortunately still not yet up to its full Industrial Strength.
Copy link to clipboard
Copied
\K is totally awesome. Not only is it easier to write than enumerating the variable-length alternatives, it's also (marginally) quicker.
It's indeed the solution to the variable-length lookbehinds. Kai's screenshot showed that already, and here's another example:
Find the words map, figure, and table if followed by a number:
Without K: ((?<=map)|(?<=figure)|(?<=table))\s\d+
With K: (map|figure|table)\s\K\d+
\R is useful too, but not nearly as a welcome a new kid on the block as \K.
Theunis: \p{Arabic} and other script identifiers and character class subtraction are indeed keenly missed. We should pester Adobe to update the the classes dropdown in the Find/Change window.
Peter
Copy link to clipboard
Copied
I’m in love \K ... 😉
Copy link to clipboard
Copied
The difference between \v and \R are really subtle... Does anyone have a real use case where \R might be more useful than \v ?
Copy link to clipboard
Copied
Is there really any difference between \v and \R? I don't see any, both match all breaks. The only difference between them and \r is that \r doesn't match forced paragraph breaks.
I did a panel that lists all classes that I (now) know of, kind of a replacement for InDesign's flyout. Did just the GREP-related things though:
http://www.kahrel.plus.com/indesign/grep_classes.html
Peter
Copy link to clipboard
Copied
@Peter – one subtle difference between \R and \v seems to be the number of matches you get, if you have \r (pargraph sign) followed by \n (forced line ending)
\R will give one match, \v will give two matches.
Uwe
Copy link to clipboard
Copied
Uwe: it's the other way around, in fact: \R mathes \r+\n, \v doesn't.
P.
Copy link to clipboard
Copied
@Peter – maybe I made myself not clear enough. Could well be.
I think, we both mean the same thing. 🙂
If one \r is followed by a \n and I use \R for my search pattern, I will get both characters with one time pressing the button in GREP find.
If using \v on the same two characters, I need two times pressing the button to get first the \r and then a second find to get the \n.
See here in the movie on my Dropbox account:
Dropbox - TwoGREPsearches-R-v.mov
Uwe
Copy link to clipboard
Copied
Uwe -- Re-reading your post I now see that we mean the same.
Copy link to clipboard
Copied
Jongware said: " \K must be "New! Now in InDesign CC 2014!"; and possibly earlier, but not as early as CS4. "
Wow.
Just tested \K and \R
Working in:
CS6 v8.1.0
CC v9.3.0
CC v10.2.0
\R
is finding any line end sequence (all vertical whitespace?)
One example with some line ends in sequence:
[return] [return newline] [newline] [newline] [newline] [return] [return newline]
will give you seven matches.
(In contrast to \v that will give you nine matches.)
Also tested in CS5.5, but no luck here…
Uwe