GREP search for single line paragraphs, CS3

I need to find all single line paragraphs, apply a paragraph style to them and apply that style's "next style" to the next paragraph.
Is there any way to do this using GREP?
Thanks

This script will do what you ask. Just change the name of the head paragraph to whatever yours is in line 11:
//DESCRIPTION: Apply Head Style to single-line paras with Next Style in Selected Story
(function() {
  if (app.documents.length > 0 &&
        app.selection.length == 1 &&
          app.selection[0].hasOwnProperty("baseline")) {
  var myStory = app.selection[0].parent;
  var myParas = myStory.paragraphs;
  for (var j = myParas.length - 1; j >= 0; j--) {
    if (myParas[j].lines.length == 1) {
      myParas[j].appliedParagraphStyle = "H1";
      try {
        myParas[j+1].appliedParagraphStyle = myParas[j].appliedParagraphStyle.nextStyle;
      } catch(e) {} // last para has one line, so ignore
} else {
   // No document open
   alert("Please select some text and try again.");
To use the script, copy it from here into an ExtendScript Toolkit document (you'll find that in the Adobe Utilities folder). Save the document into an appropriate folder and run the script from the Scripts panel with a live insertion point in the story.
To work out where to save the script, open the Scripts panel and then use Reveal in Explorer to find the User Scripts Panel folder.
If your heading style isn't at the top level in your Styles panel, temporarily move it there.
Dave

Similar Messages

  • Unable to release planned order for single line from MRP workbench

    Hi
    We are unable to release planned order for single line from MRP Planner workbench,but Select All For Release is working for all the lines for the item
    User want to release a specific line but no new requisition is generated
    It is highly appreciable if anyone could help to resolve this issue
    Appreciate the Help
    Regards
    VKPK

    It sounds like the release goes through in the workbench but the requisition does not show up in source - is this correct? If so I would check item attributes / flags for purchasing and buy. also have found some items require a purchase price to be populated in master and org

  • Search for end-of-paragraph before end of story? CS6

    Hi,
    Does anybody know of a way to search for a paragraph mark directly
    before an end of story marker? I'd like to get rid of them, e.g., in
    footnotes, where the last paragraph mark causes an unnecessary blank line.
    Thanks,
    Ariel

    I found \z on Mike Witherell's great little chart at http://www.jetsetcom.net/useful-resources/indesign-cs6-resources.html
    End of paragraph, at least in GREP is a location, not a character (the metacharacter is $) and can't be selected or replaced. Every paragraph has one. Paragraphs before the end of story also have a paragaph break, and that's what you are trying to remove at the end of your footnote story.
    @David, Why bother withthe lookahead? \z is the location, so I would presume that the search would start at the end of story and look at the last character. That has to be faster than parsing every break in the paragraph to check for the end of story location after, and there's no possibility that you will actually delete the EOS since it can't actually be selected.

  • GREP - search for anything except one character

    Trying to figure out if I can say this in GREP or not....
    I want to search for any character that's in a Superscript character style except for registration-mark symbols.  Is there a way to exclude one character from a search?
    Thanks, Phyllis

    Absolutely. Remember the '^' character that indicates 'start of paragraph'? Well ... apparently whoever devised GREP ran out of useful characters, because it's used again in the "exclude" group. It works like this:
    [0-9fuzzy]
    looks for a single character out of the set '0' to '9' (inclusive), 'f', 'u', 'z', or 'y'. Throwing in the hat reverses the query:
    [^0-9fuzzy]
    looks for any old single character except those in the set.
    The Registered mark has a shortcut of its own in the regular Find -- ^r -- so presumably it's "~r" in GREP mode. If not, copy-and-paste one from your text. So your GREP search should be (with Superscript formatting)
    [^~r]
    This marks only the next non-registered character; to find longer strings you can safely use
    [^~r]+
    -- which translates into "any string in superscript, one character or longer, and not containing the Registered mark". Yes, the short version is a bit easier to type.

  • Posting multiple tax codes for single line order in MIRO

    Hi all ,
    I have received a request from my business colleagues to investigate the possibility of posting multiple tax codes against a single line order in MIRO.
    This apparently can be a possibility for such things as training.
    I have searched a number of forums and tried and tested different ways in my develoment client but am unable to find a solution. admittedly I am no real expert in this area and would be gratefu;lt of any ideas / assistance  / etc..

    HI,  There is a possible solution for this scenario.
    1. Create 2 tax codes for VAT and SERVICE Tax at 12.5% and 12.36% respectively
    2. While posting the Invoice (TRX - FB60) following steps need to be followed.
    3. Amount has to be split into two line items
    4. Ist Line Item should have the Vat amount + 70000/- and select relevant tax code that was
        created for 12.5%
    5. Similarly 2nd Line Item should have Service Tax amount + 30000/- and select relevant tax code that    
        was created for 12.36%.
    Hope this would meet your requirement. If the solution is okay, kindly indicate the points.
    Regards
    K.Sanjai Babu

  • GREP style for one specific paragraph

    Hi all,
    I'm faced with the following problem in a textdocument I've got to rework in InDesign.
    The text is based on 3 'groups' of information. First there is a title, beginning with:
    "1.1. Title (so two digits and a paragraph),
    a body text,
    and a source, starting with: 'source: This is the source' and
    '*: this is the source'.
    Now I want all paragraphs starting with two digits in the same style, and all lines starting with 'Source' or '*' in the same style.
    I'm pretty new with GREP, but I believe that might be the solution. Or any other ideas to to this fast and automated?
    Is there a code that specifies a style for a whole paragraph?
    All help is very much appreciated since this is a very laaaarge document.
    Thanks!

    GREP styles (which you seem to think of) only apply character styles. So that's out for entire paragraphs.
    woutergeeftvorm wrote:
    Now I want all paragraphs starting with two digits in the same style, and all lines starting with 'Source' or '*' in the same style.
    Select all text and assign it your Body text paragraph style. Then use this in the Find/Replace dialog, GREP section. Find:
    ^\d+\.\d+
    Replace: leave blank, but select the name of the title style in the Change To formatting fiend.
    Press Change All. Done.

  • GREP search for \$ Dollar sign doesn't find them all?

    Hello,
    OK-I was practicing my GREP yesterday and was working with escaping out characters. Since the $ could not be found, I assumed it needed to be escaped out \$. The odd thing is, when I say find next, it skips many of them in the document?
    Anyone know why?
    thanks!
    babs

    This has been reported before; it's an oddity of ID's implementation of GREP. Nobody knows why! (*)
    It only works reliably when you do not use the escape code \$ (you were, in fact, correct to try that first!), but instead use the Unicode notation for a dollar sign: \x{0024}.
    I've noticed some strange GREP-related behavior myself: at times, it seems "Find Next" can skip a *huge* quantity of text and finds something near the end of the file; but a next "Find Next" mysteriously jumps back to the previous find position, and continues from there as if nothing happened.
    (*) I'm pretty sure it's the Adobe engineers that are responsible for this. According to Peter Kahrel, Adobe didn't write the GREP module by themselves but chose to use a free programming library called "boost". Now boost is an extremely thorough piece of work that has gone through literally years of development and dozens, if not hundreds of programmers (probably unpaid as well, since boost is open source), and I cannot imagine something like this to slip through unnoticed.
    But ... for InDesign, the Adobe programmers had to add code to cater for InDesign's own special characters and codes -- stuff like the special characters and spaces, and text variables. It's not hard to imagine a programmer accidentally changing a line of code that did the, erm, "now search for \$" stuff.

  • Compiler error for single line if

    Hi all,
    I found an interesting quirk, recently. I've condensed the problem into the following simple test class.
    public class Main {
        public static void main(String[] args) {
            final boolean myBoolean = args.length > 1;
            if (myBoolean) {
                final double result = doIt();
        public static double doIt() {
            return System.currentTimeMillis();
    }Turns out that the variable declaration on line 9 (it doesn't have to be calling a method), will not compile if I remove the scoping around the if statement. See below:
    public class Main {
        public static void main(String[] args) {
            final boolean myBoolean = args.length > 1;
            if (myBoolean)
                final double result = doIt();
        public static double doIt() {
            return System.currentTimeMillis();
    }This fails to compile with the message:
    Main.java:8: illegal start of expression
    final double result = doIt();
    Since the code is perfectly valid (as far as I'm aware), I was hoping someone might have an explanation for this strange behaviour. Oh, it fails to compile on 1.4 and 1.5 compilers.
    The only thing I can think of is that the compiler is being clever and knows the declaration is stupid since the variable is never used. However, this doesn't explain why adding the scoping around the statement allows the code to compile. FYI, this is not limited to if statements. Also happens with for loops. Must be the single line scoping issue.
    Thanks in advance,
    Adam

    Thank you so much for your insightful and considered suggestion. I hope I don't shock you too much by telling you that I have in fact tried it without the final keyword. Regardless of whether or not this gets around the compilation issue (it doesn't - did you even try it?), the question in my original post was fairly clearly along the lines of "Does anyone know why this compiles with the braces, and doesn't compile without them?"
    Does anyone have anything useful to contribute?

  • Searching for single words in Solr

    I have a Win2k8 Standard 64 bit install of CF9.0.1.  I have simple PDF document containing two words, "Seattle" and "Seahawks".  If I search for "Seattle", I get 0 results.  If I search for "Seattle Seahawks", I get the one result I expected. 
    What can I do to add better support for single word searches?
    NOTE: This does also occur with .doc and .txt files.
    Thanks,
    Merritt Chapman

    Seattle should give you a hit.
    Default query mode in Solr distributed with coldfuion is OR. (it can be changed in solrconfig)
    I suspect the actual search query is Seattle OR Seahawks
    -do you still get one hit searching for Seattle AND Seahawks ?
    So for some reason Seattle has not been put into the index.
    It can happen if its in the stop word list for the collection (but it should not) or if the synonyms file is  badly configured.
    I would analyze how Solr indexes these words (http://localhost:8983/solr/[your collection]/admin/analysis.jsp
    Select the fieldname where you store the data [summary ?]
    check verbose output
    and type  Seattle Seahawks in Field value
    Check how Solr applies filters etc

  • Search for string in paragraph and apply a new character style?

    I'm searching for a way to find a specific string in a specific text frame and make it bold. so my thought was to search and then apply a character style from my template doc. I thought this would work, but I went wrong somewhere.
    newDoc is my document. 
    //something like
    var Bios = "Representative Biography:\r want to leave this text normal.";
    var myTextFrameBios = newDoc.pages.item(i).textFrames.add({geometricBounds:[4.5277, 2.36, 8.625, 5.375], contents:Bios});
    var myTextObjectBios = myTextFrameBios.parentStory.texts.item(0);
    // IS THIS CONFLICTING with my change below? Can I apply a character style within a par styled frame?
    myTextObjectBios.appliedParagraphStyle = newDoc.paragraphStyles.item("CompanyProfile");
                                                      //Clear the find/change preferences.
                                                    app.findGrepPreferences = NothingEnum.nothing;
                                                    app.changeGrepPreferences = NothingEnum.nothing;
                                                    app.findTextPreferences.findWhat = "Representative Biography:";
                                                    app.changeTextPreferences.changeTo = "Representative Biography:";
                                                    app.findGrepPreferences.appliedCharacterStyle = newDoc.characterStyles.item("BoldBioHead");
                                                    // Perform the operation
                                                    app.documents.item(0).changeGrep();
                                                    app.findGrepPreferences = NothingEnum.nothing;
                                                    app.changeGrepPreferences = NothingEnum.nothing;

    @caseyctg – If you want to apply a character style to a text object in a specific text frame, you could restrict the scope of your script to that specific text frame:
    Example with the variable "myTextFrame" you have to define before:
    myTextFrame.changeText();
    Btw.: you are doing a text search and clearing your GREP find/change preferences at the start of the snippet? Why is that?
    You could do a:
    app.changeTextPreferences = app.findTextPreferences = NothingEnum.nothing;
    or:
    app.changeTextPreferences = app.findTextPreferences = null;
    set before the search and after the change, if you want to be on the safe side…
    Uwe

  • No Discount for Single Line Plans?

    I have been a Verizon user for a long time now with my parents, and now moving out on my own I am looking to get on my own plan. I am a teacher, and Verizon offers an 18% discount to educators. However, I spoke with a representative online and found out that the discount is not allowed on single line plans, only share everything plans. Does anyone know why this is? I was hoping to use the discount to make the price more competitive to independent pay-as-you-go providers like StraightTalk and AIO. I know Verizon has a prepaid style plan, but I don't want to have to use such an older model phone...  I love Verizon and want to stick with them, but I don't think that paying upwards of $300 more per year to stay on with them is worth it. If I was able to use the discount to take anything off of it it would make it more manageable, but I don't understand why you can't use an educator discount on a single line plan. Doesn't make any sense to me...

        I understand the value of a corporate discount SingleVerizonUser. Discounts are available on single line plans; however, it is dependent on the specific plan. Which plan do you have with us currently? If you are on a promotional plan, which is already a reduced cost, an additional corporate discount may not be available.
    JonathanK_VZW
    VZWSupport
    Follow Us on Twitter@VZWSupport

  • Search for single member in an Active Directory Group

    Hello all,
    I'm attempting to find a better method to search if a user is a member of a group in Active Directory. I currently retrieve the entire member attribute of the group.
    I need to reduce the time of the query. I would like to be able to search for a specific member (user) of the group instead of retrieving the entire member list of the group.
    I can post my current code if that would help.
    I believe the default Active Directory group object is the ldap group. I know that there are posixGroup and groupOfUniqueNames ldap classes available, but I'm not sure if Active Directory has access to those classes.
    Is my request possible using the group ldap object?

    Thanks for the reply.
    I have read the first post you gave, but not the second. I'm off to read that now.
    My main concern is that I don't have access to the DN of the user in the member attrib. I have access to their CN and uid (which is indexed). From what I can recall from when I last updated this code, I couldn't create a wildcard search filter e.g.,:
    (&(cn=All Scientists)(objectClass=Group)(member=CN=Albert Einstein*))
    If that's correct and I require a DN, is there any way around this?
    I was interested in the posixGroup and groupOfUniqueNames classes. I wasn't aware that these were available through Active Directory, but I see them listed in the AD schema (http://msdn.microsoft.com/en-us/library/ms683908(VS.85).aspx).
    If I'm correct, posixGroup would allow for a filter of (&(cn=All Scientists)(objectClass=posixGroup)(memberUid=AEinstein))
    I'm not sure how typical it is to use the posixGroup class in AD and I'll have to check with my AD team before moving forward with this. But I wanted to get some more direction/ideas before asking them to create some posixGroup objects for me.
    I'm now going to go and read the second post you linked, but I wanted to put the rest of my details out there.
    Thanks again.

  • I am trying to write a grep search for the first instance of a word in a paragraph.

    How can I identify only the first instance of 'FREE' in a paragraph and apply a style to it, without also styling the 2nd or more instance of the word?
    Thanks

    (?i)^(.+?)FREE should find the first instance in a paragraph. The (?i) makes the search case insensitive in case it wasn't typed as all caps, the ? inside the second grouping makes the shortest match for cases when there is more than one instance in a paragraph, and I've not added any quotes since I presumed those aren't actually in the text.
    I would deal with the formatting by typing FREE exactly as you want it someplace on the pastebord, then copy to the clipboard. Change to $1~c which replaces the found string with the text found in the first subexpression (.+?), which is the stuff before the first FREE, and the the formatted contents of the clipboard for the FREE.

  • GR Printing For Single Line Item With Multiple Account Assignment.

    Hi All,
    There is PO for projects (Account Assignment -P - Network) in which in a single item consist of multiple account assignment.
    Noe while entering the GR I select "Collective Slip" option but when the GR is posted system automatically select option "Individual slip" and seprate line item are printed for each account assignment.
    The printing program is standard SAPM07DR. The SAP version is 4.7. Can anyone tell what is ther any setting in configuration or is it problem in program or smart form
    Thanks & Regards,
    Omkar

    hi
    please check your form and routine used to print.

  • How to configure Two Tax Codes for single line item in work order

    Hi All,
    Please do Review the below scenario and tell me how to solve it.
    A) Certified Work Done Gross Bill Amt      100,000      
    Total Work Done Value      100,000      
    Less : Labour & Like Charges @ 30 % on Rs 100,000 =  30,000      
    Vat applicable Amount =      70,000      
    Add VAT @12.5%  Chargeable on Taxable Turnover of Rs. 70,000.00     = 8750
    Total Bill Value = 108750
    Service Tax @ 12.36% on 33% Value of Rs. 100000     = 4079
    G.Bill Amt = 112829
    Total Amt Due for Payment = 112829

    HI,  There is a possible solution for this scenario.
    1. Create 2 tax codes for VAT and SERVICE Tax at 12.5% and 12.36% respectively
    2. While posting the Invoice (TRX - FB60) following steps need to be followed.
    3. Amount has to be split into two line items
    4. Ist Line Item should have the Vat amount + 70000/- and select relevant tax code that was
        created for 12.5%
    5. Similarly 2nd Line Item should have Service Tax amount + 30000/- and select relevant tax code that    
        was created for 12.36%.
    Hope this would meet your requirement. If the solution is okay, kindly indicate the points.
    Regards
    K.Sanjai Babu

Maybe you are looking for

  • MacBook Pro: How to speed up services?

    On my laptop stopped going video signal (I have black screen).I brought the laptop into service ERC (http://www.erc.ua/), located in Ukraine. I was told there that he falls under http://support.apple.com/kb/TS2377, and they took it for repair. They h

  • What event handling code do I need to access a web site ?

    Hello I am doing a GUI program that would go to a program or a web site when a button is clicked. What event handling code do I need to add to access a web site ? for instance:     if (e.getSource() == myJButtonBible)           // go to www.nccbuscc.

  • Can I use gift cards to pay for songs just downloaded that were charged to credit card before entering card numbers?

    I downloaded songs to my playlist before entering two gift card credit numbers. I thought I would have an opportunity to put them in before end of transaction. Can I undo the charge and use the $20 gift card total?

  • Nothing is displayed in View layout in web dynrpo development

    hi , In my webdynrpo developing, i met a strange issue. When i create a view, and then double click the view to do further edit. I get below popup window that ask me to input id and password. after i input that ,and got below and it has nothing displ

  • Readers for Playbook 2.0

    What I am trying to find is a reader other than Adobe that will read ebooks as well as pdf files.  The reader will allow me to mark pages and thumbnail where I finish so that I can easily pick-up where I finished reading.  Adobe is difficult to get t