-
1. Re: CS4 can GREP do this?
Eugene Tyson Jun 24, 2010 2:45 AM (in response to Skempy)Find
\t(\w{1,4}(?!\w))
Change to
\n$1 -
2. Re: CS4 can GREP do this?
P Spier Jun 24, 2010 2:45 AM (in response to Skempy)This isn't elegant, but it seems to work:
Find /t..?.?.?.?$ and change to \n$0
-
3. Re: CS4 can GREP do this?
P Spier Jun 24, 2010 2:47 AM (in response to P Spier)Sorry that should be \t
Eugene's constuction is more elegant, but it doesn't save the Tab as you requested. To do that change the $1 to $0 in the change
-
4. Re: CS4 can GREP do this?
Eugene Tyson Jun 24, 2010 2:49 AM (in response to Eugene Tyson)Eugene Tyson wrote:
Find
\t(\w{1,4}(?!\w))
Change to
\n$1\t = tab
\w = character
{1,4} = 1 to 4 instances (so \w{1,4} finds 1 to 4 instances of word characters together)
(?!\w) = negative lookahead (it won't include a string after this, in this case I asked it to lookahead for a character after it's found 1 to 4 characters and ignore)
when \w{1,4}(?!) is enclosed in parenthesis it marks it as FOUND TEXT, i.e., (\w{1,4}(?!)) is now marked.
\n = soft return (forced line break)
$1 = copy and replace the first found text after the \n
-
5. Re: CS4 can GREP do this?
P Spier Jun 24, 2010 2:50 AM (in response to P Spier)And I read into the request that the tab should be followed by 5 or fewer charaters of any sort, putting it at the end of the paragraph, and maybe that isn't right.
-
6. Re: CS4 can GREP do this?
Eugene Tyson Jun 24, 2010 2:53 AM (in response to P Spier)Sorry I forgot that wanted to keep the tab
in that case - in the Change to box - you can insert a \t after the \n (before the $1)
Like this
\n\t$1
-
7. Re: CS4 can GREP do this?
Eugene Tyson Jun 24, 2010 2:52 AM (in response to P Spier)Perhaps the OP could clarify with an example?
-
8. Re: CS4 can GREP do this?
Eugene Tyson Jun 24, 2010 2:56 AM (in response to Eugene Tyson)What i can find with this is in bold - is that's what's needed?
<tab>abcde
<tab>abcdef
<tab>abcd
<tab>abc
<tab>ab
-
9. Re: CS4 can GREP do this?
Skempy Jun 24, 2010 3:30 AM (in response to Eugene Tyson)Hi Eugene and Peter,
Thanks for your input.
I don't think I have been clear on what my problem is. I was looking for a starting point with GREP and was hoping to work it out for myself from there.
I have long list of cars for sale similar to the one below:
Ford Galaxy one lady owner, low mileage, good runner, blue...............£3000
or
Ford Galaxy one lady owner, low mileage, good runner, air con, elec. windows
blue...................................................................................... ..............£3000
but often the tab leader is too short
Ford Galaxy one lady owner, low mileage, good runner, midnight blue..£3000
I am after a non-manual way to force the tab onto the next line when a short tab leader appears
thus
Ford Galaxy one lady owner, low mileage, good runner, midnight blue
.......................................................................................... .............£3000
So I think I have probably asked the wrong question.
Simon.
-
10. Re: CS4 can GREP do this?
P Spier Jun 24, 2010 3:39 AM (in response to Skempy)That IS a slightly different problem. You aren't asking to break the line because of the lenght of what follows the tab, but rather what preceeds it. I'm pretty sure this is doable, but the problem is that using proportional type the number ov glyphs in any given width is going to be variable, and you might end up breaking lines that don't really need it if you base this on a character count.
-
11. Re: CS4 can GREP do this?
Skempy Jun 24, 2010 4:05 AM (in response to P Spier)Ok,
So something like a positive lookbehind for 60-80 characters may give me what I want for the majority of the listings items but there may be the odd one where the Forced Line Break is added un-necessarily?
I though this might work but doesn't find anything.
(?<=.{60,80})\t
I may have a look at a script that measures each tab character's position relative to the right edge of the text frame and then adds a line break.
Thanks
Simon.
-
12. Re: CS4 can GREP do this?
[Jongware] Jun 24, 2010 4:15 AM (in response to Skempy)Lookbehind does not work with a variable number -- anything using ?, *, +, and {xx,yy} will always fail ...
-
13. Re: CS4 can GREP do this?
Eugene Tyson Jun 24, 2010 4:53 AM (in response to [Jongware])Well I am stumped
I've lots of combos in the GREP
The one I'm looking to achieve is finding the second last comma in the paragraph in the text and the following text to the end of the sentence
So it finds
Ford Galaxy one lady owner, low mileage, good runner, blue...............£3000
There has to be a way to do it - it's a regular pattern
Find <length> before tab and price
Hmm lunch time
-
14. Re: CS4 can GREP do this?
pkahrel Jun 24, 2010 5:54 AM (in response to Skempy)Simon,
The dots inserted by InDesign aren't really characters, so no matter how many dots InDesign displays, there's always just one character between the text and the price, namely, a tab. I don't think that you can achieve what you want with a GREP replacement. You'd need a script that measures the distance between the text and the price and break the line if that distance is less than some value.
Peter
-
15. Re: CS4 can GREP do this?
Eugene Tyson Jun 24, 2010 6:05 AM (in response to Eugene Tyson)Ok having some success with this
Find
\w+[^s][^.]{^,]{2,15}\t.\d+$
Change to
\n\t$0
-
16. Re: CS4 can GREP do this?
pkahrel Jun 24, 2010 6:15 AM (in response to Skempy)Eugene,
How do you count the number of leading dots? Anyway, here's a script to do what Simon wants:
var minimum = 5; try { app.findGrepPreferences = null; app.findGrepPreferences.findWhat = "~y(?=£)"; var tabs = app.documents[0].findGrep(true); var distance; for (var i = 0; i < tabs.length; i++) { distance = tabs[i].insertionPoints[1].horizontalOffset - tabs[i].insertionPoints[0].horizontalOffset; if (distance < minimum) tabs[i].insertionPoints[0].contents = "\n"; } } catch (_) {}Set Indesign to millimeters and set the minumum distance at the first line of the script (here it's set to 5 mm. Save the script and run it.
Peter
-
17. Re: CS4 can GREP do this?
Jeremy bowmangraphics Jun 24, 2010 6:15 AM (in response to Skempy)You might try the combination of a couple of em spaces and a Right Indent Tab character, all given a dotted underline.
-
18. Re: CS4 can GREP do this?
Eugene Tyson Jun 24, 2010 6:18 AM (in response to pkahrel)I'm not counting the dots - I don't know how. So I was concentrating on amount of words before the tab.
If it can be scripted the that's cool.
-
19. Re: CS4 can GREP do this?
Skempy Jun 24, 2010 6:34 AM (in response to pkahrel)Thanks Peter, this is what I thought. A GREP would have been good because other InDesign users would be able to modify them to suit different templates.
With a script, I would have to do the tweaks as and when required. (Unless I used an external text file that provided the settings.)
Simon.
-
20. Re: CS4 can GREP do this?
Skempy Jun 24, 2010 6:41 AM (in response to pkahrel)Peter,
Thanks for the script. I just reminds me that my scripting attempts are still very primative.
I would have iterated through every character to check if it was a tab, in a certain paragraph style. I would have been able to do the measuring bit in a very similar way. I hadn't considerd using a GREP search to get all the tabs!
I may now revisit some of my older scripts and try this.
Thanks to everyone for their contribuitons.
I am leaving now to attend the London InDesign User Group meeting.
Simon Kemp




