Grep Question

Can I specify a paragraph style in a grep query?
I want to have a grep style that is only triggered if the paragraph before has a certain style in use. I figure if I can specify the style in a look behind this should be possible no?

yeah.. imagine you have a space after attribute on paragraph style 1, and space before on paragraph style 3. I am looking for a way to make it so that I can avoid a double sized space when style 1 is followed by 3.

Similar Messages

  • Add space between set of Symbols - Grep Question

    hi everyone,
    I have another Grep question someone hopefully can help with. I need to find the following symbols in my long document < > + =      
    All these symbols need space either side of the character. I would like to setup a grep expression and have it find the symbols and add spaces either side. So far I can find each symbol but can't figure out how to add spaces before and after with the replace feature?
    find:
    =|<|>|+
    replace:
    can anyone help..
    lister

    Use this line in Find option: \+|\=|<|>
    Use this line in Replace option: <space>$0<space>
    Siva

  • GREP question re: character style

    I am trying to take a block of text and change everything in that text to a certain character style. What's the correct GREP expression to do that? I know I could just highligh the text in question and apply the character style, but I need to use this in a FindChangeByList script, so I need to do it using GREP expressions. Thanks.

    What I'm really looking for is this. When I want to format a paragraph in a paragraph style, sometimes there are underlying character styles that I need to clear first. So I higlight the block of text, go to character styles and select [None], thus clearing that text of any character styles. Then I apply my paragraph style. I've found that if I don't do this, I get unexpected results.
    I know that the active characer styles is always the last character style that was used, but I wish that the default was simply the [None] character style. I'm forever having to go back to [None.]
    I'm trying to build some scripts that automate this for me, but perhaps there's a much easier way to think about this problem.
    Message was edited by: JoJo Jenkins

  • A grep question

    Hi all,
    Sorry, I know its a Java forum but all of you know Unix shell much more than me and might be able to help me. I came across following in a Unix shell programming tutorial:
    * Execute statements as long as a condition is false
    until grep "sort" dbase_log > /dev/null
    do
    sleep 10
    done
    echo "Database has been sorted"
    * Example executes until grep is unsuccessful
    Doesn't grep looks for word "sort" in the dbase_log file? It does not actually execute "sort" as sort command, right? Why it says that "Database has been sorted"?
    Any help is greatly appreciated.

    Not sure if that's sarcasm or what, but I figured
    you'd already gotten your answer, so there was no
    harm in a little wisecracking.Not sure, what do you mean, I got to forum after a
    while and saw the replies. Yes, I figured out my
    answer, just thanked you, b/c that was the best
    answer that could be to the first posting which
    compared my question to 'sex' question and I found it
    non-sence.Okay, I'm confused. I'm not sure what you're saying here.
    If you're thanking me for giving you the real answer, your aim is off. :-) Somebody else posted the real answer.
    If you're thanking me for being a wiseass, you're welcome, but I'm just doing what becomes naturally.
    I thought maybe you were being sarcastic because you didn't like my wiseass comment.
    Anyway, I'll let it drop now, before I confuse myself any more.

  • GREP Question:  Style em spaces that precede only certain triggers within a paragraph

    Hello,
    Up front:
    I do not know GREP well enough to begin to tackle this.  And as usual, I'm in a pinch!
    Also, if you're the visual type, just look at the second to the last paragraph at the bottom, and that may be enough to help you devise the GREP style.  Otherwise, bear with me, I have to think this through...
    I have a list that spans pages of events.  The events are formatted as follows:
    ☐Box City EventNameSpecific Month EndPara (this is a single paragraph in a story of a hundred such paragraphs)
    On paper, each event will need to be preceded with a filled specific-colored box (☐).  I would like this box to be made from a strikethrough applied to an em space using grep, since that is very easy to create using a character style and only requres one setting (the thickness of the strikethrough).
    There is a legend at the bottom of the page, detailing about 14 types of events.  Some of the different types of events will require the same colored box.  But in all I have 7 different colors of boxes in the legend.
    I'm looking to create...
    7 character styles, one for each color (consider this done already)
    1 paragraph style (essentially done, but missing the GREP)
    7 GREP styles (or more as necessary) specifically to apply only to the em space that precede specific sets of text strings
    If I need, or if it is simpler to create 14 GREP styles within the paragraph style, that's fine.  But I understand we may be able to do something like this... (Target phrase 1 | Target phrase 2 | Target phrase 3) in between parenthesis to identify multiple possible triggers within the same rule. 
    I'm fine whether it's 7 or 14 rules in there, I just want to be able to update them over the course of time as necessary - but it won't be for another season at least if I do.
    I don't know GREP well enough to piece together what I need.  Vaguely familiar with look aheads and look behinds.  I do understand it may be easier if the em space is in between other characters, so in my example below I've inserted hairspaces.  But ultimately I want the em space to be flush or nearly flush to the left of the frame.
    For my example below:
    I only want to apply character styles to em dashes based on the strings in bold.
    The strings of text that will trigger the GREP will vary in number of words and may or may not contain a dash.
    I want to ignore Citynames regardless of number of words... Chicago vs. San Francisco vs. Vancouver, BC for example.
    I want to ignore MonthofYear which appears after the second tab.
    The tabs will have set stops as a regular part of the paragraph style.  I'm including them in my example below in case it helps to visualize possible anchors to use in GREP.
    I want the style to be easy enough to modify, for example if I want to simply add an (EEEE New Eventname) to the list of possible options within a rule that triggers a specific character style.  See below should make it clearer.
    So here's what I'm thinking...
    Within the Paragraph Style, the first two examples of GREP Styles should be able to respond to the following criteria:
    Rule 1:  If the paragraph contains any of the following, then apply Char Style 1 to the em dashes in those paragraphs. Use a unique GREP expression for each phrase below where each uses Char Style 1 or use a single GREP expression to capture all three possible triggers:
    ABC BB Invitational
    ABC Xxxxxxxxxxxxxx
    ABC MM-Xxxxxxxxxxxxxxx
    Rule 2: If the paragraph contains any of the following, then apply Char Style 2 … and so on
    Global ABC Xxxxxxxxxxxxxxx
    Global WXYZ Xxxxxxxxxxxxxxx
    I cannot count on “ABC” or “Global” being the trigger for the style, if you know what I mean.  I need the entire phrase (ABC BB Invitational) to be the trigger… if it exist in its entirety, then apply the style to the preceding em dash in that paragraph.  This way if there are any mispellings or if we launch a new event type which ends up flowing in to my document I will know it.
    hairspace  emspace  tabspace CitynameOneWord ABC BB Invitational tabspace MonthofYear
    hairspace  emspace  tabspace  Cityname TwoWrds ABC BB Invitational tabspace MonthofYear
    hairspace  emspace  tabspace  Cityname MultiWrds ABC BB Invitational tabspace MonthofYear
    hairspace  emspace  tabspace  Cityname TwoWrds ABC MM-Xxxxxxxxxxxxxx tabspace MonthofYear
    hairspace  emspace  tabspace  Cityname MultiWrds ABC Xxxxxxxxxxxxxx tabspace MonthofYear
    hairspace  emspace  tabspace  Cityname TwoWrds Global ABC Xxxxxxxxxxxxxxx tabspace MonthofYear
    hairspace  emspace  tabspace  CitynameOneWord Global WXYZ Xxxxxxxxxxxxxxx tabspace MonthofYear
    hairspace  emspace  tabspace  CitynameOneWord Global Special Xxxxxxxxxxxxxxx tabspace MonthofYear
    hairspace emspace tabspace  CitynameOneWord Globl Special WRONG SPELLING  tabspace MonthofYear
    I hope this makes sense and isn't too unnecessarily redundant.  Time for bed.  Fingers crossed someone will post at least one GREP string, so I have some magic code for tomorrow morning!  Ideally, it would be great if you would include a brief explanation of waht the string is doing, but minimally, please do use one of my text stings above, so I know what to mess with and what not to.  ;-)
    <says prayer>
    Thanks!
    Rick

    Well, for a moment I thought I had an idea of how to do this with GREP styles, but I realized it wouldn't work, and I'm not sure it's possible unless you are able to make a separate style for every possible string between the em space and the trigger text. You want to use the lookahead because you want to find that text, but you don't want to select it or apply the style to it, but a lookahead can't handle the kind of variability on string length that you need to work based on just the bolded text at the end.
    It would actually be easier to use paragraph styles based on the bolded text that include a nested character style, I think. That could be handled by find change, but I think the best thing is probably to move this over to scripting.
    Rather than just move the discussion, though, I'm going to ask you to cross post so there are two threads on the chance that someone else who doens't visit scripting might have another idea for you here.
    Here's a link to scripting: InDesign Scripting

  • [CS3] GREP question

    I am using the following code to find all compound words:
    (\w\w+)-(\w\w+)
    However, if the first word has initials, such as "U.S.-China," it does not find it.
    So I change the code to be:
    (\w(.?)\w+.?)-(\w\w+)
    This works. Now GREP finds any compound word whether or not there are initials but when there are no initials it also selects the last letter of the word prior to the compound. For instance what is in brackets here is selected:
    th[e mid-September]
    Why is this happening and how can I fix it?
    Thanks,
    Tom

    Tom Tomasko wrote:
    [...] However, I found that following also works:
    ([\w+.*]+)-(\w+)
    Yes it will work, and as a side effect ... it will also pick up '+' and '*' !
    A list of characters inside [ Character Set brackets ] loose the magical properties they have outside them. \w is still regarded as 'any word character' (0..9, A..z, and the equivalent in other scripts), but the period does not longer match "any character" but only itself. There is no need to grab more characters using either + or * because anything inside the Character Set brackets always will match one single character, and you need the '+' right after it to get it to repeat.
    So all you need is this:
    ([\w.]+)-(\w+)
    WhatTheGrep's breakdown:
    ( Begin Group #1
    [ Inclusion: any character in this group
      \w Any word character (A..Z, a..z, _, 0..9)
      . The character “.”
    ] End Inclusion Group
    + Any character in this group may occur once or more times; longest possible match will be taken
    ) End Group #1
    - Literal character “-”
    ( Begin Group #2
    \w+ Any word character (A..Z, a..z, _, 0..9); may occur once or more times; longest possible match will be taken
    ) End Group #2
    (1[\w.]+1)-(2\w+2)

  • A grep question about inverting items on paragraphs

    In these entries is required to invert the order and replace the first period with a tab:
    Brigard Henry, 211
    Brigard Louise, 71, 78-79, 242, 248-249, 316
    (^.+, )(\d.+)$
    or (^.+,) (\d.+)$
    but the result only works for entries with a single number.
    (the periods may be fixed later...)
    211     Brigard Henry,     
    316     Brigard Louise, 71, 78-79, 242, 248-249,

    Absolutely perfect. It is a powerful grep!
    (So far of my archaic possibilities)
    Thanks a lot, Pixxel.
    Can I now print this list perfectly made.
    Happy weekend.
    52, 91n, 189, 192n-193n, 193, 206, 225, 233n, 244, 260, 282n, 292, 318              Ana María
    244               Ana María Bastida
    282n               Ana María de la Borda
    282n               Ana María de Vargas Flórez
    193               Ana María Elisa
    193n               Ana María Fernández de Cuéllar

  • Another GREP Question

    I'm attempting to use GREP to search for any lines that contain the following: "word or words": Then change it to: "word or words":
    The problem is not changing it's finding.  I'm using this string to try to find these words or phrases in parentheses with the column at the end:  (")(\w+)(")(:)
    Thus far it works great at finding what I want with one exception.  It can't find any multiple words in parentheses it can only find cases with sing words.  As far as I understand (\w) should find "Any Word" but in this line there is a + which means One or More Times, yet it only find One time Not One Or More.  Could someone please help me understand why this is not working the way it appears it should be?

    It's not working because multiple words have spaces between them, and you aren't allowing for that.
    I suspect what you really want to find is (".+?"): though I haven't tested. That ought to find the shortest match of anything between quotes and followed by a colon.

  • GREP question-Proper syntax

    Hello
    I am trying to insert a graphic frame and ANCHOR it to a specific point on the page and I must do this about 300 X
    I watched this video over a dozen times and can't produce the desired results
    http://www.theindesigner.com/podcasts/tid45_theindesigner_45.mp4
    The best way to explain is with screenshots. I worked on this for 4 hrs last night using every possible combination of factors without success

    You seem not have understood Michael Murphy's tutorial at all.
    In the tutorial, the frame was inserted at the beginnig aof a paragraph that actually had text in it, so for the GREP query you need to enter ^. (note the dot after the caret) which means the first character in the paragraph, and you need to set the find formatting options to the correct paragraph style, which in this case seems to be the pre-anchor heading style you've created, so that's done. This style cannot be used anywhere else.
    The reason this didn't work was that ID doesn't seem to regognize the end of paragraph as a valid character found with the dot, and your paragraph has nothing else in it. You can change your qurey to either ^\r or just \r (since that's the only thing in the paragraph it doesn't matter whether it is the first thing or not -- it always will be) and ID will now find the correct spot.
    In the change field you want to insert the contents of the clipboard which is ~c (lowercase) and keep the found text (your paragraph break), which means replace it with iteself, which is $0 so the change string will be ~c$0, which is exactly what Michael said to use in the video.

  • GREP question - spaces before am & pm

    Hello,
    I am wondering if there is a GREP which will find a number with an am or pm and add a space between the number between the am or pm?
    My contributers to the magazine I typeset keep typing times in as "7pm" for example, our style says it should be "7 pm". Changing these by hand is a pain.
    Thanks!!!

    You don't really need the plus sign after the digit.
    Interesting choice of the "or" statement, too. My first reaction was to use (\d)([ap]m) which also works, and it probalby would be a good idea to add a work boundary to make it look like (\d)([ap]m\>)
    Not quite sure how to add an end of word to your "or".... Maybe (\d)(am\>|pm\>)
    I wonder which method runs faster.

  • GREP question: Changing all caps to proper name punctuation

    Hello,
    I'm working on my subscription renewal letter.
    In our mailing database, all names of people and business are in capitals. I need to change them to regular capitlization for the letter.
    Example: "JOHN SMITH" should be "John Smith"
    I know how to find the text, but I don't know exactly how to repace it. Help would be much appreciated.
    Regards,
    Eric

    I found a script (coding below) by Dave Saunders: http://jsid.blogspot.com/2005/08/script-of-day-smart-title-case.html
    I need it to be slightly modified so that instead of applying to the selected text, it finds (?<=Dear\s|Cher\s).+
    //DESCRIPTION: Converts selected text to title case smartly
    // Customize this script by either editing these arrays:
    var ignoreWords = ["a","an","and","the","to","with","in","on",
    "as","of","or","at","is","into","by","from","for"];
    var intCaps = ["PineRidge","InDesign","NJ","UMC"];
    // or by creating text files named ignoreWords.txt
    // and intCaps.txt in the script's folder
    ignoreWords = getIgnoreFile(ignoreWords);
    intCaps = getIntCaps(intCaps);
    try {
    myText = app.selection[0].texts[0].contents;
    } catch(e) {
    exit();
    theWords = myText.toLowerCase().split(" ");
    //First word must have a cap, but might have an internal cap
    myNewText = "";
    for (var j = 0; theWords.length > j; j++) {
    k = isIn(intCaps,theWords[j])
    if (k > -1) {
      myNewText = myNewText + intCaps[k] + " ";
      continue;
    } else {
      if ((isIn(ignoreWords,theWords[j]) > -1) && (j != 0)) {
       myNewText = myNewText + theWords[j] + " ";
      } else {
       myNewText = myNewText + InitCap(theWords[j]) + " ";
    app.selection[0].texts[0].contents = myNewText.substring(0,myNewText.length - 1);
    // +++++++ Functions Start Here +++++++++++++++++++++++
    function getIgnoreFile(theWords) {
    var myFile = File(File(getScriptPath()).parent.fsName + "/ignoreWords.txt");
    if (!myFile.exists) { return theWords }
    // File exists, so use it instead
    myFile.open("r");
    var importedWords = myFile.read();
    myFile.close();
    return importedWords.split("\n"); // Could filter these, but what's the point?
    function getIntCaps(theWords) {
    var myFile = File(File(getScriptPath()).parent.fsName + "/intCaps.txt");
    if (!myFile.exists) { return theWords }
    // File exists, so use it instead
    myFile.open("r");
    var importedWords = myFile.read();
    myFile.close();
    return importedWords.split("\n"); // Could filter these, but what's the point?
    function getScriptPath() {
    // This function returns the path to the active script, even when running ESTK
    try {
      return app.activeScript;
    } catch(e) {
      return e.fileName;
    function isIn(aList,aWord) {
    for (var i = 0; aList.length > i; i++) {
      if (aList[i].toLowerCase() == aWord) {
       return i;
    return -1;
    function InitCap(aWord) {
    if (aWord.length == 1) {
      return (aWord.toUpperCase());
    return (aWord.substr(0,1).toUpperCase() + aWord.substring(1,aWord.length))

  • Grep Question: removing dates and brackets

    I am trying to remove
    [01/01/1996-12/31/1996]
    wherever it appears in text.... the dates would all be different and sometimes how they appear.
    Is there a way to remove brackets and whatever is within them?
    I did this once and cannot remember how!
    Thanks!

    Do you also have brackets surrounding things you want to keep? If not, searching for \[.+?\] ought to work, I think. Repalce with nothing

  • GREP question, hard return&tab after lines ending in (, space)

    I have a problem that I have been banging my head against the wall for hours trying to figure. I have pages and pages of remote codes I need to format in a specific way. This specific way causes a problem that creates the right side of my columns to look haggard with spots of comma spaces, example:
    Abex                 5011, 5286
    Accurian            5140, 5452
    Accuscan          5005, 5014
    Admiral              5003, 5004,
           5005, 5014, 5015, 5018,
           5025, 5035, 5040, 5041,
           5055, 5165, 5308, 5455
    I hope that comes out looking like I mean it
    There is a picture if it helps. Anyhow. I need it to look like this:
    I hope this helps. The thing is I have figured this out before and I forgot to save the style. I thought I did. I didn't. Sucks. But I did make it so that on lines ending with a comma and space it would hard return and tab.
    Please please help. This has my mind numb trying to figure it out and I have pages and pages of these codes to work through.

    @ GrantH
    That is an easy fix, which I would easily do, but it doesn't resolve the issue that the lines should not end in commas.
    @Jongware
    None taken. I have done something like this before. I know I have because the second picture I included is from a manual I have done before that shows it as such. Granted... that was a while ago and I may be mistaken on the text given for input. However, I'm "pretty" sure I remember having the same issue with the commas at the end and resolving it.
    @Hakkenlid
    This pretty much works for me with the exception of a few trouble spots where the Find just seems to skip over perfectly good matches. So far, this gives me a lot more help than where I was at though.
    @Hakkenlid
    This is what we are going with. It keeps the most readability and completely resolves my comma issue. Saved the expression for later. I really appreciate your help. My Friday started off to a much better start that I was looking forward to.

  • GREP: Apply to first instance only

    Hi,
    Another GREP question for you if you can help.
    Situation is trying to apply a character style before a specific word, i.e. Applied Character Style "four".......
    There are 4 words (lets call them: one, two, three, four) which are a common occurence and will always appear after the text that needs to have the applied character style, but my issue crops up when one of the four words appears twice or more times in one line and the GREP applies it to the 2nd or more instance of this word, i.e. Applied Character Style "one" random text "one"
    I am using these greps in the same paragraph style:
    ^.*(?= one)
    ^.*(?= two)
    ^.*(?= three)
    ^.*(?= four)
    I only want to have the GREP to apply to the first instance only - hope this stuff above makes sense?
    Thanks

    It's because GREP is greedy, by default.
    The expression
    ^.*(something more)
    will always grab as much characters as possible, before processing "something more": effectively, it will match anything up to the very last occurrence of that text.
    You can instruct GREP to not match greedy by adding a '?' after the repeat command code:
    ^.*?(?=\b(one|two|three|four)\b)
    -- the question mark can be added to each of the "repeat-this" codes: +, *, and ? ("!??" would mean: "match '!' zero or once, but uses the shortest match possible).
    I condensed your list of four commands into one, because it seems to me that all of them would get matched in turn, leading to problems when you have both "one" and "two" in the same sentence. With your GREPs, first all up to "one" would get marked, then all up to "two". Mine uses 'whatever comes first'.
    (I also added 'word boundaries' \b before and after, because you wouldn't want to match the 'one' in "Mr. Jones".)

  • Indesign Grep style question

    Hello,
    I have a question about Indesign. I want to make the text after a certain character like a hair space for instance bold. This must be set in a paragraph style. I think this can be done with GREP styles. I have tried several things but it doesn't make sense to me.. Does anybody know if this can be done or is there a better way to do this?
    Thanks!

    Apply 'bold' character style to text:
    (?<=~|).

Maybe you are looking for

  • Error when starting Netscape Calendar Server: Module: , Label: 355, Service error: #0x13209

    When starting Netscape Calendar Server, the following error message appears: <BR><P> Module: , Label: 355, Service error: #0x13209 <P> The three ACIs listed below need to be present in the Directory Server in order for Calendar server to work properl

  • Blackberry world isnt loading

    I keep getting errors when trying to open up blackberry world. Its been going on for about a week. At times it works but most of the time it doesn't.

  • Filter query with Odata in UI5

    Hello All, Please suggest how to perform a filter operation for a similar query as below. The query runs good in browser but does nt turn up in UI5 (chrome security is disabled ) http://gatewayhostname:8000/sap/opu/odata/sap/ZSALESORDER_SRV/SalesOrde

  • Select group of images from IPAD

    I would like to know if it is possible to browse group of images or Album from IPAD(flex 4.5 mobile SDK)?

  • Adobe Flash won't update in Firefox

    For some reason, whenever I try to update to the newest version of Flash, it downloads fine and FF says it's been installed, but when I check, I still have 10.1.82.76...says that in FF and in the programs section. It's not just one computer either, i