Numbering of the GREP search result

Hi all

I am trying to apply some paragraph styles to various items in my document, but rather than static reference to the paragraphs in question (whose position can be subject to change in the future), I try to do a GREP search result-based. The chapters follow the same structure, with a subtitle of chapter ("Chapter 1, Chapter 2, and so on"), followed by a paragraph with the title of the chapter, followed by the first paragraph of the body.

Now, it is easy for me to find the chapter number using a GREP search, and I would like to know if it is possible for me to read the number of paragraph of this search result. In this way, I can start the paragraph numbers of the remaining items on their position relative to the subheading and then apply the styles to paragraph appropriate for them.

All the best and thanks in advance,

Julian

p.s.: as a reference, this is the result of the search:





// Find chapter subheading and apply



app.findGrepPreferences = app.changeGrepPreferences = null;



app.findGrepPreferences.findWhat = "(?i)Hoofdstuk \w*\r";



var myStartLine = myDocument.findGrep(); // Save search result for future reference as a first line



app.changeGrepPreferences.appliedParagraphStyle = myPGS_CS ;



myDocument.changeGrep();



Just another idea: If you can find your first paragraph apply the paragraph style, and then loop through all paragraphs in the document and compare the name of the applied style. If you found one, the next paragraph is the current a + 1, the second is the current a + 2.

var curDoc = app.activeDocument;

app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "Head \\d\\r";
app.changeGrepPreferences.appliedParagraphStyle = "h1";

var startLine = curDoc.findGrep();
curDoc.changeGrep();

var allParas = curDoc.stories.everyItem().paragraphs.everyItem().getElements();

for ( var p = 0; p < allParas.length; p++ ) {
    var pStyleName = allParas[p].appliedParagraphStyle.name;
    if ( pStyleName == "h1" ) {
        allParas[p+1].appliedParagraphStyle = "p1";
        allParas[p+2].appliedParagraphStyle = "p2";
    }
}

Tags: InDesign

Similar Questions

  • Link to shift + click on the Google search result

    How can I open new tab/windows by link shift + click on the Google search results?

    It is the way in which Firefox opens the link.

    My current setting is Ctrl + click opens a new tab in a new background tab, shift + click opens the link on the same page.

    Firefox 40.0.3 Windows XP

    For the Google site, you can set preferences on the Google page via the top gear icon to the right of the results, click this button to open the list of menu and select search parameters.

    Where results open: Open search results in a new browser window.
    

    Google settings are stored in a PREF cookie on your computer, you must create an exception to allow him to keep cookies for Google to save settings, otherwise you will have to repeat.

  • column of file missing in the bookmarks search results

    In the library of all bookmarks page, when you search for bookmarks, the returned list does not record information. When I find dead links, I would go to this bookmark folder to see if there are any more stale bookmarks that are. I guess that more people use tags as the folders and subfolders to sort their bookmarks? For example, under Science, I have astronomy, physics, etc.

    column of file missing in the bookmarks search results

    Install the "Show Parent folder" and (also useful) extensions "Go Parent Folder" for what you want, you want to really read the knowledge base article.

    Sorting and rearranging bookmarks - Firefox (and in collaboration with bookmarks)
    http://KB.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox

    For more information about the extensions I use, see

    http://dmcritchie.MVPs.org/Firefox/Firefox.htm#ext_table
    For more information on keywords shortcuts, see

    http://dmcritchie.MVPs.org/Firefox/KWS.htm

    If it solves your problem, please mark it as resolved.

  • Request OA region shows the previous search results when moving between pages

    Hi all

    I have a custom Page of OA, which is a query based on a LOV region to search for names of devices. The problem I am facing is once the device name is searched and I'm going to another page through quick links and back on the same page Search Device, it shows the previous search results. I am does not keep AM for all navigation page.

    I already tried things:
    4 K I tried refreshing VO using clearcache and reset methods on the VO.
    2 get, click on the OK button of the query in ProcessFormRequest region and the Go button I use forwardImmediatelyToCurrentPage. And in the process request method that I question the results manually when will click on a button. Otherwise I do it manually where clause condition 1 = 2 and ensure that the VO returns no rows.

    But still, I am not able to get rid of the issue.

    The used code is pasted below for your reference. It is urgent. Can you please provide pointers.


    ' Public Sub processRequest (pageContext OAPageContext, OAWebBean webBean)
    {
    super.processRequest (pageContext, webBean);
    Try
    {
    Am = (VpaAdminAMImpl) pageContext.getApplicationModule (webBean) VpaAdminAMImpl;
    TkvpaDeviceSearchVOImpl deviceAll = am.getTkvpaDeviceSearchVO1 ();

    deviceAll.clearCache ();
    deviceAll.reset ();
    deviceAll.setWhereClause ("1 = 2");
    deviceAll.setWhereClauseParams (null);
    String query = deviceAll.getQuery ();
    System.out.println ("request getSearchResult: =" + query);
    deviceAll.executeQuery ();

    OAQueryBean queryBean = (OAQueryBean) webBean.findChildRecursive ("region1");
    String goAction = queryBean.getGoButtonName ();
    If (PageContext.GetParameter (goAction)! = null)
    {
    getSearchResult (pageContext, am, webBean);
    }
    }
    catch (Exception ex)
    {
    throwException ("SearchDeviceCO.processRequest", ex);
    }
    }


    ' Public Sub processFormRequest (pageContext OAPageContext, OAWebBean webBean)
    {
    super.processFormRequest (pageContext, webBean);
    Action string = pageContext.getParameter (EVENT_PARAM);
    OAQueryBean queryBean = (OAQueryBean) webBean.findChildRecursive ("region1");
    String Go = queryBean.getGoButtonName ();
    System.out.println (PageContext.GetParameter (Go));

    If (PageContext.GetParameter (GB)! = null)
    {
    pageContext.forwardImmediatelyToCurrentPage (null, false, "N");
    }
    }

    Public Sub (VpaAdminAMImpl am, pageContext, OAWebBean webBean OAPageContext) getSearchResult
    {
    Try
    {
    String device = pageContext.getParameter ("deviceSearch");

    StringBuffer sb = new StringBuffer();
    If (device! = null & & device! = "")
    {
    SB. Append ("nom_peripherique =" "");
    SB. Append (Device);
    SB. Append("'");
    }

    String sql = sb.toString ();
    TkvpaDeviceSearchVOImpl deviceAll = am.getTkvpaDeviceSearchVO1 ();
    deviceAll.setWhereClause (sql);
    deviceAll.setWhereClauseParams (null);
    String query = deviceAll.getQuery ();
    System.out.println ("request getSearchResult: =" + query);
    deviceAll.executeQuery ();
    } catch (System.Exception e)
    {
    e.printStackTrace ();
    }
    }


    Thanks in advance,
    Abhishek Mishra

    Hi Abhishek,

    Please try the code below in your controller ProcessRequest
    This will clear the previous search from the cache.
    Example of
    OAQueryBean queryBean = (OAQueryBean) webBean.findChildRecursive ("QueryRegionName");
    queryBean.clearSearchPersistenceCache (pageContext);

    Hope that helps :-)

    Kind regards
    Chaouki

  • How can I incease the width of column in the google search results?

    The search results show all the words and the URL so I want to be able to increase the width of column - I can't see an icon that allows me to do

    The full URL is in the link, and an extension script or a user could replace the short green text (< name > element) with the full link, but I suspect it should be customized wrote, I don't know that you won't find anything in that direction right now.

  • If FF 39.0 on a new PC with Windows 7 Pro 64 bits - in the sidebar search results bBookmarks are slow - is new facility there a solution for this?

    Recently I've just set up a new PC with Windows 7 Professional (64 bit) as the operating system. I just imported bookmarks from my PC in one. HTML file, I created from my old PC. Now whenever I type a search term in the search box to refine my search for one of my favorites of many, sometimes even by typing in the term search begins to lag while I'm typing more letters. Search term/terms once entered, it seems to take 15-20 seconds before the results list appears. This used to be almost instantaneous in this same version of FF (39.0) on my old PC 64 bit of Windows 7 (Home Premium) to bring up the results. I already tried to install the add-on called "signed 1.3.1 - 0 maintenance of the premises and this time there really doesn't make any difference that it helped when I got FF 38.0.5 on my old PC to Win 7 64-bit." Can it still be addressed. Please update as soon as POSSIBLE with the solution.

    Start Firefox in Safe Mode {web link} by holding down the < shift >
    (Mac options)
    key and then from Firefox. Is always the problem?

  • By clicking on the Google search results within a framework gives white screen

    Back to this story is that I use Firefox and I use a simple frames home page where my fave links (ebay, craigslist links primarily) are on the left of the screen frame and google opens up on top of the right frame. When I do a google search, it does what it does and gives me his search results. Normally, when I click on one of the Google results the rest left image and the right will go to the link I clicked on. Not today, if. All I get is a blank screen and in the status bar. The left frame is still there. In this case on 2 computers. That is to say, doesn't have a problem. Is Google? Firefox? Or a combination of both?

    Here is the code for my main frames page. I don't need to register a 2nd.

    1 htm

    This has happened

    Don't know how many times

    == May 25th, 2010

    Try to clear your cache and cookies.

    1. Open the Tools menu, then select clear recent history...
    2. In the time range to clear: drop-down menu, select all.
    3. Click the arrow next to Details to display the list of items that can be cleared.
    4. Select Cookies and Cache.
    5. Click clear now.
  • Siri has not provided the appropriate search results

    Hello

    I have some problems when using Siri.

    My iPhone running iOS 9.1.

    My Siri language is set to English.

    Whenever I would ask Siri to find something, it never of the results correct answer.

    For example, "web search for telescope.

    When I tried to ask Siri search for something on the web. He don't answer translates in English, there always answer Chinese results and which is not what I'm asking.

    I think it can using Baidu search engine to return results to me.

    But the question is that Baidu never gives English results.

    I even tried to check if they meet currently in Chinese. But it doesn't work.

    Baidu is famous for its precision of bad research.

    Is it possible to apply Siri answer Bing or Google search results?

    Hello

    Your software needs updating to ios 9.2

    See you soon

    Brian

  • Cannot delete the file search results

    I uninstalled a program but the files in the folder that has been deleted appear always in my indexed search results, I want to delete them, but it says the file "Does not exist" which is the reason why I want to remove in the first place... because it no longer exists, why have it appear in my results. These files will leave eventually or will they have a permanent dwelling home in my research indexed.

    Hi Gamemaster406,
    Thank you for visiting the Microsoft Answers forum.
    To resolve this problem, you will need to index your computer.
    Click Start > type "index" > click on indexing on search results Options.
    Then click on advanced > click on rebuild.
    This will re-index your computer.

    Post back with the results please
    Thank you

    Martin
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • How to open the Win7 search results window?

    Win7 start > search works well.

    But - the list of search results immediately closes when you click on any found object.

    Is it possible to keep this first results list open while different elements are extracted?

    Often the first choice turns out not to be the one who really wanted to, so it takes some trial and error.

    It is a drag to have to keep re-entering the same search term.

    Thank you.

    Click the 'Other results' link and it will open in a window of Windows Explorer.

  • Thumbnail images in the Google search results? (Using Adobe Muse)

    Hello

    I've been hunting around a large number of pages (including the webmaster tools) my question is simple, but the answers seem not to be!

    Someone at - it an easy and quick way, adding a thumbnail that will appear next to a site search result in Google?

    Obviously, this is a site designed and downloaded directly from the Adobe Muse.

    Some tips would be much appreciated!

    Thank you

    That is entirely up to Google and like so many things depends on your ranking and if / or send you your money.

    Mylenium

  • The dominant search result page template / resources

    Hello guys,.

    I use UCM 11 g and I'm serach result page customization.

    When we look on AAU, we get a page of search results. This search result page has a drop of two downs (top-right) "Change view" and "Action Research" in the blue band.

    I may add an option of custom in "Action Research" drop-down list. Could you please share the 'model' or 'Resource' name should I replace?

    Before the UCM 11 g, we add include our drop down options in "custom_searchapi_result_options" but I have not found any template like this in UCM 11 g.

    Thank you
    MAK

    Hello

    I can't give you the complete code, but yes, I can give you the similar code avialable.

    See book of Bex Huff, Chapter 8, page 152.

    I hope that you need not what anyone else, still you need my help then give me a shout.

    Thank you

    MAK

  • Need help with the GREP search delete numbers

    Hello everyone,


    I have the text with the following reference numbers, I need to remove the numbers before each start of paragraph, but some figures following the space, some of the figures are without space. Please help me remove these figures with GREP or MS Word search or other means

    Before:

    1 Apple

    2Ant

    4 animals

    55 flowers

    56Doctor

    466 painters

    467Teacher

    After:

    Apple

    Ant

    Animals

    Flowers

    Doctor

    Painters

    Teacher

    Thank you
    Siva

    Try this GREP and replace it with nothing:

    {^ \s{0,}\d+\s{0,}

  • By clicking on the Google search results lead to correct the page and then automatically redirects to a Yahoo page

    I'll go into search parameter in Google, Google results appear, click on one of the results on the Google page, the page back but then turns immediately to a Yahoo page. What follows is one of the pages Yahoo that the browser makes a redirect to: https://search.yahoo.com/yhs/errorhandler?hspart=gt & hsimp = yhse-gt & q = http % 3A % 2F % 2F www.doglitter.com%2FContent%2Fcss%2Fbullet_macIE & type = 576859

    Hello

    Looks like you may have some malware. Please check your add-ons for all suspicious extensions:

    • Tools (or

      ) > Addons > Extensions

    • Alternatively, you can type Subject: addons in your address bar and then click on "Extensions".

    Delete all suspicious extensions that you find. Please follow the section Troubleshooting extensions, themes and problems of hardware acceleration to resolve common Firefox problems to find the cause. A useful way to find the culprit is disabling half of your modules, if it redirects is more then the culprit is in the half you off, otherwise it is the left half you activated.

    When find you what is causing your problems, please let us know. This might help others with the same problem.

  • change/stylize the re ' search results for use on screen .htmlText

    Hello

    I am working on a search function but have a little trouble finishing some details display. The following code works very well to find and display the text in an xml file, but I want the results displayed differently.

    Use the following as a source XML, I would like to:
    -Put highlighted in red (var searchTerm) search term when found in the xml file
    -Add a few characters before and after the search term to give the term found little context

    For now, how could I add 3 characters before and after the search term, as follows: "The first tex" - and highlight 'first' in red?

    Thanks much for any help.
    ~ chipleh

    var xmlFileToSearch:XML = 
    <xml>
         <sim>    
              <bodyText>
                   <page number="0">        
                        <para><![CDATA[The first text to search]]></para>
                   </page>
                   <page number="1">
                        <para><![CDATA[The 2nd text to search]]></para>
                   </page>
                   <page number="2">
                        <para><![CDATA[The 3rd text to search]]></para>
                   </page>
                   <page number="3">
                        <para><![CDATA[The 4th text to search]]></para>
                   </page>
              </bodyText>
         </sim>
    </xml>
    ;
    
    function searchXMLFile():void
    {            
         var xmlBody:XML = xmlFileToSearch.sim.bodyText[0];
         var pageList:XMLList = xmlBody.page; 
         //String to search for
         var searchTerm:String = "first";  
         for (var i:int = 0; i < pageList.length(); i++)
         {  
              var item:XML = pageList[i];
              var textList:XMLList = item.para.text();    
              for (var j:int = 0; j < textList.length(); j++)
             {   
                   var t:XML = textList[j];   
                   //if the string is found
                   if (t.toString().toLowerCase().indexOf(searchTerm.toLowerCase()) != -1)
                   {      
                        //traces "Page 1. - The first text to search"
                        trace("Page " + (Number(item.attributes())+1) +". - "+t.toString());
                        //How could I add 3 characters before and after the search term, like so: "The first tex" 
                        //- and highlight 'first' in red?   
                        searchDisplay.htmlText += ("Page " + (Number(item.attributes())+1) +". - "+t.toString());            
                   }   
              } 
         }
    }
    
    searchXMLFile();
    


    t.substring(t.indexOf(searchTerm) - 4, t.indexOf(searchTerm)) + "" + searchTerm + "" + t.substr(t.indexOf(searchTerm) + searchTerm.length, 4);
    

Maybe you are looking for

  • Satellite A30-203 does not start

    I have a laptop A30-203. When turn on/off all the front lights indicates but unit not start

  • Why Defender lasts more than 12 hours to run?

    I had this thing for 2 years and the Defender has never taken this time by time it took 25 + hr.  This is BS, it should be faster then that.  What's the deal?

  • Installation of Windows 7 Boot from sd card

    So, I want to install 64-bit x on my hp probook 4420 s after all is to copy the windows setup files. and then start from an sd card. but after "windows is loading files" it stuck at windows startup can you guys help me with this problem :( Post propo

  • BlackBerry Smartphones blackBerry owner first needs help.

    I got my first BlackBerry this weekend and am currently waiting for the battery to run out before you make the first charge as suggested by the guy in the Orange shop.  My battery is currently very low. So, today I added my email account and active B

  • HP PSC 1315 all-in-one printer

    Everytime I turn on my printer it prints a test page.  How can I stop doing this and waste?