GREP find the paragraph style

Hi guys,.

I use this grep to search for all words that use the body text paragraph style.

However, I get the same result if I specify a paragraph style to find or not.

The result is always the same. Why is this?

app.findGrepPreferences = null;

var found = app.findGrepPreferences.findWhat = "\\b\\w+?\\b";

found.appliedParagraphStyle = "Body text";

Found = App.activeDocument.findGrep ();

Alert ("this document has" + found.length + "words");

gives the same result as

app.findGrepPreferences = null;

var found = app.findGrepPreferences.findWhat = "\\b\\w+?\\b";

Found = App.activeDocument.findGrep ();

Alert ("this document has" + found.length + "words");

app.findGrepPreferences=null;
var found = app.findGrepPreferences.findWhat="\\b\\w+?\\b";
app.findGrepPreferences.appliedParagraphStyle=app.activeDocument.paragraphStyleGroups.item("body").paragraphStyles.item("Body text");
found=app.activeDocument.findGrep();
alert("This document has "+found.length+" words");

(^/)

Tags: InDesign

Similar Questions

  • GREP find/replace + paragraph Styles

    Hello

    I'm editing a long document and have benefited from the assistance of the community already, but being new GREP Style, find/replace, I need to ask for additional help.

    Below a screenshot of the script (original). Two blocks of text you see anticipated by the icons have have styles of different paragraphs. Icons are placed like custom glyphs.

    Now, the last line with C2, 9, 14,... is the target of this post. They are buses of London and I created a paragraph with another icon. The copy that I work with unfortunately is as you see. Buses will follow «;»

    Resulting to place a \r after the semicolon and assign the new paragraph style. The item to work with is (probably) the last "," before the registration of the bus. All entries have it in the same way, where a search/replace global grep should work fine.

    My attempts:

    I used of a previous debate (? < =------;)) [^ ;] + $ to match everything from the end until the last semicolon, but then I found the problem preserving the matched characters and placing \r (using the (? < =-;). start at the beginning and stops at each point comma + space)

    So question: how to stop at the first semicolon at the end and replace the space with \r to create a new paragraph?

    Then, it is two question :-)

    From my previous attempts, I noticed that when you replace the semicolon + space with \r, and change the style of paragraph at a time (from Rail to Bus) caused the Rail paragraph style change (logic) to the style of Bus. So I tried to say the paragraph style of the track "Following paragraph Style is style of Bus" (and not to change the paragraph style in find/replace), but in a way that no longer works.

    Second question is: given to split the find/replace in two steps, how then transform / apply to newly created paragraph the correct style of Bus?

    Thank you in advance for your valuable assistance. So far, the community has been great!

    Antonio

    Original

    Screen Shot 2016-07-12 at 22.32.23.png

    Result for

    Screen Shot 2016-07-12 at 22.54.51.png

    Hi Antonio,.

    If I understand correctly, in 2 regex [1 click play with Multi/find-replace our friend Martinho da Gloria]:

  • Cannot find the paragraph style, which is apparently in use

    Hello.

    I'm working on a document with the text that I have imported the word. After you have applied all my character and paragraph styles, I check to see if there are styles original Word still in use. Can I do a search/replace for those still persistent and change them to mine. There is a paragraph style, named normal, what don't get me. It seems to be in use - when I try to remove it, he asks what style should be used to replace it. It shows also upward on the Panel of cross references when I try to create a new cross reference. I tried to change its definitions to something with the big guy and a strong color, so I could find it easily on the pages, but not luck. When I use find/replace to the style, I get the message "cannot find match". I even tried the police search of the style, I do not use on my styles, but nothing appears. Am I missing something?

    Thank you.

    The next thing to try would be exporting to IDML. See remove minor corruption by exporting

  • Cannot find the paragraph styles

    When I create a table, the text style sometimes as "Table Style 2" in paragraph styles section but but when I click on the triangle to the list of different styles, he is nowhere to be seen. "" I'm new on this so sorry if it's something obvious but is there more models on the list of those that appear immediately and if yes how do for them?

    Using Pages on El Capitan 10.11.1 v5.6.1. When I insert a new table, the Table Style 2 paragraph Style is visible in the text: Style tab. Click on the triangle produces a rollout with the list of paragraph Styles. I can't reproduce the problem you describe.

  • Style GREP in the paragraph style

    I am wanting to create a GREP style that uses a character style. Whenever certain words (no classes) appear followed by dates. Sometimes, it's a unique and sometimes more than one date. For example:

    No class 7/11.

    No class 7/11-8/11.

    What I have so far is:

    No class \d+.

    It works very well through the words 'No class' and the first digit, but not for the whole sentence. I tried different combinations, but nothing works.

    Can anyone help?

    Jay

    The first expression grep in your screenshot does not work because you have added / /, which I should have mentioned should be omitted (including all spaces preceding) - sorry about that. It should read this:

    No class\s [-\d /] +.

    The hyphen is necessary to match the dates like 7/11-8/11.

    As the level of positions with dates and parental guidance optionally, this one works on your example:

    \d[-\d\. My] + [my] (, demands. +)?

    which is a little more secure that Reese, it's because it requires that the date ends in M or y. The? Suite (, requires) makes between it brackets in option. Remember that grep is case-sensitive: If your months can be tiny m thus, use [-\d\.] MMY] for your character class. You may need to tighten the grep to match the dates according to the formats possible.

    Peter

  • I can target fat with GREP - in dialog paragraph styles?

    Hello.

    I have a number of paragraphs which are mainly "regular" (as the font style: ordinary) but they also have a few bold throughout.

    I'm doing a paragraph style that will apply a character style to text bold using GREP.

    Is there a GREP code for this (to not apply the character for the "BOLD" style and nothing else)?

    I know it's easy to do in the Find/Replace dialog box, but I wonder about the paragraph style dialog box in the GREP section.

    Any help would be greatly appreciated.

    Hello

    Indeed, it is easy to do.

    You do not have to use GREP, you can use the query to search/replace text.

    Start by creating your character for "BOLD" style. (Let's call it "CBold")

    Then create your paragraph style, with your desired settings (let's call it "PReg")

    Finally, click on search it icon 'specify attributes to find', 'Bold' and replace it with character styles and paragraph previously defined:

    Who will do the job.

    Please note that this "erases" all text attributes (for example, italic...) in your paragraph.

    Also, it will apply changes to paragraph all if no style is specified in the search for options: including securities i.e.

    So, be careful when you use this method...

  • GREP to change paragraph style?

    Many people, I have a one for all what you out there smart people. I think GREP can be used to change the formatting in the next instance, but I have no idea how set up.

    I have a very long document, essentially a telephone directory of type list of names, telephone numbers, addresses, well over 150 pages. Paragraph styles are fairly simple, two only by registration. The name/phone number is "BOLD", with a tab on the right points pointing to a phone number that is aligned to the right of the column. The following lines are at the same level on the left, not fat, but indented 6pts. I placed the text file and assigned the NameListing paragraph style to the whole thing. I would like to use GREP to find lines of addresses and change the paragraph style NameListingAddress.

    Here's a screenshot to give you an idea of screen. The left column is correctly formatted with both styles, the right column is "raw", all paragraphs formatted with the paragraph style NameListing.

    What is an application suitable for GREP? If so, how I set it up to only change paragraphs who "do not have tabs? It would save me a crapload of time.

    Screen shot 2011-11-15 at 8.10.43 AM.png

    THANKS again! -Dina

    The easy way would be to do the reverse of what you're trying: together all the paragraphs of your NameListingAddress style (rather than NameListing). And then do a plain old ordinary search for tabs, do not put anything in the line of "change of...". "(or put another tab in) but the value of change in Format to the NameListing style paragraph in the context menu. Change (after you have checked some of them to make sure it's doing what you want).

    It is probably a way to do this with GREP, but it would be much more difficult.

  • Where is the paragraph style tools in Indesign CC2014?

    Hello! I just started to use IDs through creative cloud on a new computer (using CC CS6 for two years), and the installer gave me rather than CS6 CC2014. So it is a question only on CC2014.

    Where is the window paragraph styles? Specifically, how can I edit, create and organize the paragraph styles, and how do I get a window up on the main screen with all stated styles? All these things were easy to find in CS6, but I can't find them in CC2014. The only thing I get (and with a bit of customization). is a drop-down list on the main toolbar, which allows me to choose from among the existing options on an existing document.

    There is no option of paragraph Windows Styles > Styles.

    There is no option under Type of paragraph Styles.

    The only paragraph window that appears is designed for text editing as you go along, don't not to apply styles.

    Using the options all point me back them to the entrance for CS6 and tell me to go to Type > paragraph Styles (which does not exist).

    I can't get a window up on the main screen to instantly apply styles in a list. I only get this drop, which has no other options.

    Can someone tell me some updated guidance or explain where all paragraph options are and how do I use them? If not, can I go back to CS6? It was easy and intuitive on the front, and now it's not...

    Thank you!

    Nothing has changed on the styles. It's exactly the same thing as CS6. Perhaps you need to restore your preferences.

  • Self-propagating ampersands in GREP in a paragraph style

    Hello. I use GREPs in paragraph styles (InDesign CS6) the color of specific words and struck a strange thing, when the words I'm trying to color include an ampersand (&).

    The style works fine the first time, but if I call the paragraph style, and extra sales begins to appear in the GREP expression, not only to the expression, I am changing, but other expressions that include an ampersand as well.

    Example: I enter track ^(?i)------& field

    The next time I have change a grep in this style, the grep goes to the track to ^(?i)------& & field. ^(? (I) then track------& & & field.

    If I go out the extra mostapha, only to see them back. And have a space or not having not spaces on each side of the ampersand does not work

    impact on the problem. I tried to use \s instead of space, but it makes no difference. I also tried dumping my InDesign preferences and export the document as a file .idml in an effort to clear all funky.

    ampersand1.jpgampersand2.jpg

    Has anyone seen this? Thank you!

    Kelly

    Sorry, I have never seen it before.

    A vague assumption: many styles with Grep?

    But maybe you try this instead:

    (? i) a\x e {26}

  • How to change the paragraph style to each paragraph that contains only one anchored object?

    Hello

    I have a document in word that should be converted in indesign. The document contains instructions, each step followed by an image.

    I managed to import the document into Indesign and applied a paragraph with numbering style to everything (text, image).

    Now, how do I change the the paragraph style to each paragraph that contains only an image? I need to get rid of the numbering.

    Thanks in advance.

    If the images are all anchored objects, you can use find/replace to find the anchor point and change the paragraph style only once for all paragraphs.

  • Script will not apply the paragraph style

    Hello

    I'm new to scripting in InDesign (CS3), and I'm trying to understand why the scipt below does not apply a style in the following text file? :

    < ASCII-WIN >

    < ParaStyle: Heading 1 > who are we? < ParaStyle >:

    For ease of reading, I have shortend the text file to just two lines.

    The script that I use to open and to format the text file is:

    Create a new document.

    myDocument var = app.documents.add ();

    Set the units of measure and the origin of the rule.

    myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;

    myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;

    myDocument.viewPreferences.rulerOrigin = RulerOrigin.pageOrigin;

    Get a reference to the first master spread.

    var myMasterSpread = myDocument.masterSpreads.item (0);

    Get a reference to preferences on the margins of the first page in the Master spread.

    var myMarginPreferences = myMasterSpread.pages.item (0) .marginPreferences;

    Now set up the page margins and columns.

    myMarginPreferences.left = 4;

    myMarginPreferences.top = 70;

    myMarginPreferences.right = 70;

    myMarginPreferences.bottom = 78;

    myMarginPreferences.columnCount = 2;

    myMarginPreferences.columnGutter = 14;

    The margins of page and columns for the right-hand page.

    var myMarginPreferences = myMasterSpread.pages.item (1) .marginPreferences;

    myMarginPreferences.left = 48;

    myMarginPreferences.top = 70;

    myMarginPreferences.right = 70;

    myMarginPreferences.bottom = 78;

    myMarginPreferences.columnCount = 3;

    myMarginPreferences.columnGutter = 14;

    Adding Master Page items

    var myMasterSpread = myDocument.masterSpreads.item (0);

    var myLeftPage = myMasterSpread.pages.item (0);

    var myRightPage = myMasterSpread.pages.item (1);

    var myLeftFooter = myLeftPage.textFrames.add ();

    myLeftFooter.geometricBounds = [70, 742, 728, 528];

    myLeftFooter.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

    myLeftFooter.contents = SpecialCharacters.autoPageNumber;

    myLeftFooter.parentStory.characters.item (0) .pointSize = 11;

    myLeftFooter.parentStory.characters.item (0) .leading = 14;

    var myRightFooter = myRightPage.textFrames.add ();

    myRightFooter.geometricBounds = [48, 742, 728, 542];

    myRightFooter.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

    myRightFooter.contents = SpecialCharacters.autoPageNumber;

    myRightFooter.parentStory.characters.item (0) .pointSize = 11;

    myRightFooter.parentStory.characters.item (0) .leading = 14;

    myRightFooter.parentStory.characters.item (0) .justification = Justification.rightAlign;

    Adding master text frames

    var myLeftPage = myMasterSpread.pages.item (0);

    var myRightPage = myMasterSpread.pages.item (1);

    var myLeftTextFrame = myLeftPage.textFrames.add ();

    myLeftTextFrame.geometricBounds = [70, 70, 714, 528];

    myLeftTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

    myLeftTextFrame.textFramePreferences.textColumnCount = 3;

    myLeftTextFrame.textFramePreferences.textColumnGutter = 14;

    Add a label to make the image easier to find later.

    myLeftTextFrame.label = "BodyTextFrame";

    var myRightTextFrame = myRightPage.textFrames.add ();

    myRightTextFrame.geometricBounds = [70, 48, 714, 542];

    myRightTextFrame.textFramePreferences.firstBaselineOffset = FirstBaseline.leadingOffset;

    myRightTextFrame.textFramePreferences.textColumnCount = 3;

    myRightTextFrame.textFramePreferences.textColumnGutter = 14;

    Add a label to make the image easier to find later.

    myRightTextFrame.label = "BodyTextFrame";

    Link the two frames using the nextTextFrame property.

    myLeftTextFrame.nextTextFrame = myRightTextFrame;

    The substitution of Master Page points and adds text

    var myTextFrame = myDocument.masterSpreads.item (0).pages.item (1).textFrames.item (0) .override (myDocument.pag es.item (0));

    Add text by setting the contents of the insertion of a string.

    In JavaScript, "\r" is a return character.

    .silence myTextFrame.insertionPoints.item (0) = "dok\r";

    Adding and applying a paragraph Style

    var myParagraphStyle = myDocument.paragraphStyles.item ("title 1");

    try {}

    var myName = myParagraphStyle.name;

    }

    {} catch (MonErreur)

    //The style of paragraph don't have not exist, so create it.

    myParagraphStyle = myDocument.paragraphStyles.add ({name: 'Title 1'});

    }

    We need to create a color. Check if the color already exists.

    myColor var = myDocument.colors.item ("Green");

    try {}

    myName = myColor.name;

    }

    {} catch (MonErreur)

    //The color have not exist, so create it.

    myColor = myDocument.colors.add ({name: 'Green', model: ColorModel.process, colorValue:[100,0,100,0]});})

    }

    Now set the formatting of the paragraph style.

    myParagraphStyle.appliedFont = "Arial";

    myParagraphStyle.fontStyle = "Bold";

    myParagraphStyle.pointSize = 24;

    myParagraphStyle.spaceAfter = 24;

    myParagraphStyle.spaceBefore = 24;

    myParagraphStyle.fillColor = myDocument.colors.item ("Green");

    Apply the style to the paragraph.

    myDocument.pages.item (0).textFrames.item (0).paragraphs.item (0) .applyParagraphStyle (myParag raphStyle, true);

    You can also use:

    myDocument.pages.item (0).textFrames.item (0).paragraphs.item (0) .appliedParagraphStyle = //myParagraphStyle;

    Import a text file

    Display a standard dialog box open the file to select a text file.

    var monFichierTexte is File.openDialog ("choose a text file");.

    If you selected a text file, and if you didn't press Cancel,

    Place the file of text on the first insertion point after the title.

    If ((monFichierTexte! = "") & & (monFichierTexte!) (= null)) {}

    myTextFrame.insertionPoints.item(-1).place (myTextFile);

    }

    Place a graphic

    Display a standard dialog box open the file to select a graphic file.

    var myGraphicFile is File.openDialog ("choose a graphic file");.

    If you have selected a graphics file, and if you didn't press Cancel,

    Place the graphic file on the page.

    If ((myGraphicFile! = "") & & (myGraphicFile!) (= null)) {}

    var myGraphic = myDocument.pages.item (0) .place (myGraphicFile);

    //Since you can place multiple graphics at once, the place method

    //returns a table. For the graph you have placed, get the first

    //item in the table (beginning of JavaScript arrays with element 0).

    myGraphic = myGraphic [0];

    //Create a style object to apply to the graphic image.

    var myObjectStyle = myDocument.objectStyles.item("GraphicFrame");

    try {

    var myName = myObjectStyle.name;

    }

    catch (MonErreur) {}

    //The an object style have not exist, so create it.

    myObjectStyle = myDocument.objectStyles.add({name:"GraphicFrame"});)

    }

    myObjectStyle.enableStroke = true;

    myObjectStyle.strokeWeight = 3;

    myObjectStyle.strokeType = myDocument.strokeStyles.item("Solid");

    myObjectStyle.strokeColor = myDocument.colors.item("Green");

    //The frame containing the graphic is the parent of the graphic.

    myFrame var = myGraphic.parent;

    myFrame.applyObjectStyle (myObjectStyle, true);

    //Resize the frame to a specific size.

    myFrame.geometricBounds = [0,0,600,600];

    //Fit the graph in the image proportionally.

    myFrame.fit (FitOptions.proportionally);

    / / Next, mount the frame to the resized image.

    myFrame.fit (FitOptions.frameToContent);

    var myBounds = myFrame.geometricBounds;

    var myGraphicWidth = myBounds [3] - myBounds [1];

    //Move the graphic frame.

    var myPageWidth = myDocument.documentPreferences.pageWidth;

    var myTopMargin = myDocument.pages.item (0).marginPreferences.top;

    myFrame.move ([myPageWidth-myGraphicWidth, myTopMargin]);

    //Apply a wrap to the graphic frame.

    myFrame.textWrapPreferences.textWrapType = TextWrapTypes.boundingBoxTextWrap;

    myFrame.textWrapPreferences.textWrapOffset = [12, 24, 12, 24].

    }

    I hope someone can point me in the right direction.
    Thanks in advance.
    Ron

    Hey, Ron.

    The problem has nothing to do with your script. You can see if you attempt to place the file from indesign tagged text by hand.

    Your instinct for divide and conquer for debugging is a good - have a short text file to work with is very useful - of course this is also true for the script.

    During the validation of the scripts on the forum, please do not use the syntax insert > feature Java which lies behind the > arrow in the toolbar. Otherwise, cut and paste your script are difficult requiring manual corrections.

    Anyway, your problem is that each paragraph can have only a single paragraph style, and it's the last one that you define.

    So in your IDTT file, you set the heading 1 paragraph style, enter the content of the paragraph and then set the style of paragraph votes to zero.

    If you have included a line break before setting the style of paragraph votes to zero, you must set the None style for the following paragraph. But since you have not, it resets just the style to the current paragraph.

    In short: success back before .

  • How to insert an ellipsis in the paragraph style?

    Hi all

    In the paragraph style, how to insert the selection to the last paragraph symbol.

    Please someone help me solve this problem.

    I have attached the screenshot of the sample. Like that, I have to insert "selection" symbol (three points) in the indesign paragraph style options.

    ellipse.jpg

    Very simple to do this, follow these steps

    1. double click on the paragraph style if you created (if this isn't the case create a new paragraph style, see the image)

    2. in paragraph style options, choose paragraph nets and do all the settings, see the image

    Hope this will help you

    Thank you

  • Balls, created in the paragraph style options in Indesign

    Hi all

    In the paragraph style, how to create bullets before the text and after the text also.

    Please someone help me solve this problem.

    I have attached the screenshot of the sample. Like that, I must create in indesign paragraph style options.

    Capture.JPG

    Thank you...

  • Graphic object based on the paragraph Style style?

    I just checked the documentation of the API and saw nothing on the point about this.

    Is it possible to write a script that applies a Style object to a jpg image based on the paragraph Style applied to this image jpg online online?

    Hello

    I did the following:

    var curDoc = app.activeDocument;
    
    app.findGrepPreferences = app.changeGrepPreferences = null;
    app.findGrepPreferences.findWhat= "~a";
    var allFounds = curDoc.findGrep();
    
    for (var i = 0; i < allFounds.length; i++) {
      var curFound = allFounds[i];
      if (curFound.allGraphics.length > 0) {
        var pStyleName = curFound.paragraphs[0].appliedParagraphStyle.name;
        if (pStyleName == "paraStyle") {
          var rect = curFound.rectangles[0];
          rect.appliedObjectStyle = curDoc.objectStyles.itemByName("myStyle");
        }
      }
    }
    

    Kai

  • How to get the paragraph style menu to detach?

    I wish that the paragraph style menu to behave the way the menu character, that is, as its own independent box. Crazy me a little tied to any "other Panel" - no matter what the name of this Panel, it's that it is attached to.

    Thank you very much!

    Just drag it off the coast in the page.

Maybe you are looking for

  • Apple Watch do not measure rest

    Hi all I had a watch for a few weeks now and somehow, rest time is measured not at all. Here are the screenshots of the application of the activity and the app shows. Has anyone had the same problem and fixed it? So watch phone has been restarted and

  • Photosmart 5520 Warmup problem

    This is my first post, so I can't do this properly. I have a HP Photosmart of 5520 is almost a year. It worked fine until a couple of months. It is connected to a desktop computer using the AMD operating system. The problem is probably easy to fix so

  • replacement of the network card on compaq presario cq60-430sa

    Hi, I have a compaq presario cq60-430sa with an atheros b, g network card pre installed, just improved to a Wireless N Router and want to enjoy higher speeds offered, can someone tell me which cards will be or used to adapt Thank you Castro

  • How to display the notification icon in v4.2 to v4.5 versions

    Hi all 1. work on BB v4.2 (8100 Simulator) 2 opportunity BB JDE 4.2 3. the request is: I would like to show a notification icon at the top of the BB device with my request. found in version 4.7 and v4.6, I used of the API of the suite Import net.rim.

  • IP cost configuration

    Helllo,We want to pay users for issues of intellectual property they want to buy, but I don't see a way to configure this cost, which varies according to the number of purchased points.If I configure in fixed cost it doesn't need me to set the number