Forum Replies Created
-
AuthorPosts
-
Jeremy Howard
ParticipantI know I am late to the game on this one but my ears always perk up at the mention of GREP…
Brett, have you considered using line breaks (AKA soft returns)? You can get the results that you are looking for using soft returns rather than paragraph returns with this GREP string:
GIRL(.+)+\K.+(?=$)
BONUS: This will work with a minimum of 3 lines (separated by soft returns) and there is no maximum number of lines!
See my screenshot for an example:
On a different note, David, How do you post images on these threads?
Jeremy Howard
ParticipantHey there! What you are trying to do is very similar to the GREP string that you provided in your post. Here’s what you’re after:
(?<=,).*?(?=;)
A breakdown of the GREP string:
(?<=,) – this is a positive look-behind, that is saying that we only want to find characters that come directly after a comma and a space.
.*? – this is “zero or more characters” the reason that I opted for this instead of the “.+” is because “.*?” is what’s known as a non-greedy specifier. It will match the minimum amount of characters before it stops formatting. On the other hand, “.+” is a greedy specifier, it will match as much as it possibly can before it stops applying the formatting. This causes issues when you are trying to access small piece of text within a list.
(?=;) – this is a positive look-ahead. This is saying that we only want to format the text that comes before the semi-colon and lets the GREP string know where it should stop formatting characters.
This solution will work for single and multiple comma affiliations because it matches from the first “, ” through the “;”.
Jeremy Howard
ParticipantHmmm… I honestly don’t know. What an incredibly frustrating bug! If I were in your shoes, my next action would be to reinstall InDesign all together. I know it’s time consuming but then again, so is dealing with this issue while you are trying to hit deadlines!
I wish I could be more help
Jeremy Howard
ParticipantHave you tried resetting your InDesign preferences? Launch InDesign and immediately hold the control+command+shift+option keys. A dialog will appear asking you if you are sure that you want to reset all of your preferences, click “Yes” and see if that helps.
Jeremy Howard
ParticipantAh yes, to make my solution work, you would need to turn multiline on with — (?m)
Making the complete GREP string:
(?m).+,(?=.+,.+$)\K.+
Jeremy Howard
ParticipantIt just occurred to me that the string that I provided is matching and formatting the comma before “Any Town”. A slight tweak to the GREP fixes this:
.+,(?=.+,.+$)\K.+
Jeremy Howard
ParticipantHello Amanda,
The way to accomplish this would be to utilize “\K”.
Here is the GREP I used to make it work when testing:
.+(?=,.+,.+$)\K.+
The first bit — .+ matches all characters that fall before the positive lookahead
The positive look ahead — (?=,.+,.+$) matches to a comma, 1 or more characters, another comma, 1 or more characters and then the end of the paragraph.
Now for the really nifty part. The “\K” is used to ignore everything that has been matched by the GREP before it. That means that all of the matched characters from the first part of the GREP string — .+(?=,.+,.+$) are essentially being used to tell the second part — .+ (match 1 or more characters) where to begin.
So the first part of the GREP string (the part before the “\K” actually matches all of the text in your paragraph up until the second to last comma, then we use \K to tell the GREP to apply the style to every character after that match.
April 7, 2019 at 1:15 pm in reply to: Find and Replace is not working for Forced New Line Character #115913Jeremy Howard
ParticipantJust off the top of my head, they rather than ^n and see if that works
Jeremy Howard
ParticipantAh, but that is thinking more complicated than most (at least from a readability and troubleshooting perspective).
I broke out the pieces of the script in order to simplify it, people new to scripting will find the drawn out version easier to read and will almost certainly get more out of it.
Condensed scripting != Simple scripting
:)
Jeremy Howard
ParticipantOh, I see! So, what you will want to do is this:
var mySelectedCells = app.selection[0];
var myTargetRows = mySelectedCells.rows;for(x = 0; x < myTargetRows.length; x++){
myTargetRows[x].select(SelectionOptions.ADD_TO);
}Jeremy Howard
ParticipantHey Michel,
You can access the rows of the selected cells this way:
var mySelection = app.selection[0].rows;
Cheers!
Jeremy Howard
ParticipantHey Kal,
Thanks for the response! I actually ended up figuring it out. Oddly enough, InDesign saw my selection as “[object Cell]” – even though I had two entire rows selected! Once I got the “[0]” added to the end of “app.selection” (like you indicated in your reply) I was able to get the rows just fine. The reason I was stuck earlier is because it never occurred to me to look for “rows” inside of an “[object Cell]”…
Here is what I ended up doing:
var myRows = app.activeDocument.selection[0].rows;
Thanks again!
April 2, 2019 at 6:11 am in reply to: Script to take selected frame (artwork @ 10%), open new document with 100% scale #115756Jeremy Howard
ParticipantHere is a better version that copies the selected image to a new document, dynamically sizes it to 100%, centers it on the page and exports the page to a PDF that is named using the original image name.
// Begin Script ////////////////////////////////////////////////////////////////////////////////////
//set selection as variable
var thisItem = app.selection[0];//create new document
var myNewDocument = app.documents.add();//duplicate selected item to new document
var myDuplicatedItem = thisItem.duplicate(myNewDocument.pages.item(-1));//get image within the frame
var myLinkedItem = myDuplicatedItem.pageItems[0];
//get name of the linked image
var myLinkName = myLinkedItem.itemLink.name;//strip extension from linked image name
var myLinkName = myLinkName.split(“.”)[0];//find the horizontal and vertical scale integers
var myHscale = 100 / myLinkedItem.horizontalScale;
var myVscale = 100 / myLinkedItem.verticalScale;//Scale the image around its center point
var myScaleMatrix = app.transformationMatrices.add();
myScaleMatrix = myScaleMatrix.scaleMatrix(myHscale, myVscale);
myLinkedItem.transform(CoordinateSpaces.PASTEBOARD_COORDINATES, AnchorPoint.centerAnchor, myScaleMatrix);//fit frame to content
myDuplicatedItem.fit(FitOptions.frameToContent);//get width of the full-sized item
var dupedItemWidth = myDuplicatedItem.geometricBounds[3] – myDuplicatedItem.geometricBounds[1];
//get height of the full-sized item
var dupedItemHeight = myDuplicatedItem.geometricBounds[2] – myDuplicatedItem.geometricBounds[0];//get the x coords we need to center the item on the page
var xCoordsCalc = (myNewDocument.documentPreferences.pageWidth – dupedItemWidth) / 2;
//get the y coords we need to center the item on the page
var yCoordsCalc = (myNewDocument.documentPreferences.pageHeight – dupedItemHeight) / 2;//set frame bounds in order to center the frame on the page
myDuplicatedItem.geometricBounds = [yCoordsCalc, xCoordsCalc, (yCoordsCalc + dupedItemHeight), (xCoordsCalc + dupedItemWidth)];//move the image to fit into the centered frame
myDuplicatedItem.fit(FitOptions.contentToFrame);//Set Name of exported pdf to match the name of the linked image
var myFile = File(“/Users/admin/Desktop/” + myLinkName + “.pdf”);//export the pdf
myNewDocument.exportFile(ExportFormat.PDF_TYPE, myFile, false, “High Quality Print”);// End Script ////////////////////////////////////////////////////////////////////////////////////
-
AuthorPosts
