GREP repeat inside look behind

I can't figure out why my GREP won't work.
(?<=^\s*\d+)[\l\u]
I want to find any paragraph which starts with zero or more spaces, followed by one or more digits which is followed by any letter. But I only want to select the letter (to check it's formatting and apply paragraph styles accordingly), and not the spaces/digits. However, it seems like I can't use the + and * operators inside a lookbehind function since these searches don't reveal anything.
The following expression works, but it includes the spaces and digits:
(?<=^)\s*\d+[\l\u]
And this works but only works for two initial spaces and one digit:
(?<=^\s\s\d)[\l\u]
I could manually change the expression to match the four different ways that are needed in my document but I'd prefer it if it can be solved with just one expression.

Lookbehinds have to be of a fixed length, so you cannot use any of the operators +, *, or ?. In addition, behavior with OR strings of different lengths is, well, "undefined" (From memory: I think only the longest string gets considered?)
For a simple query, one or two digits for example, you could use the OR operator like this:
((?<=\s\d)|(?<=\s\d\d))[[:alpha:]]
but you are talking about *any* number of spaces followed by *any* number of digits. That's a lot of OR combinations.
SimonLinden wrote:
..  this works but only works for two initial spaces and one digit:
(?<=^\s\s\d)[\l\u]
I could manually change the expression to match the four different ways that are needed in my document ..
If it's just four, are those One or two spaces, one or two digits? That ought to be possible.

Similar Messages

  • Grep style positive look behind

    I am trying to create a grep style in InDesign CC 2014 to make anything after an em space a certain character style. I have come up with
    (?<=~m[[:punct:]]\l\u\s)*?
    but it doesn't work. Must contain punctuation, spaces and words.
    Any suggestions would be appreciated.

    The correct look-behind for the em space would be (?<=~m) and what you want to find goes outside of that. (?<=~m).+ will find everything after an em space up to the end of the paragraph. (?<=~m)\S+ will find up to the next white space (so the first word following the em space). (?<=~m)[^~m]+ will find everything following an em space up to the next em space.
    It's not really clear to me what you are trying to do here. It's also not clear why you think you need a GREP style rather than a simple nested style.

  • GREP - Positive Look Behind - find text beyond space

    I have a GREP in a paragraph style with a positive look behind. This search finds characters up to a space and applies a style, but does apply the style beyond a space.
    What do I need to include in my GREP search to find text that follows a space? TIA

    Right. It only finds upper and lower case letters, so the match ends at anything that isn't one of those. Do you want to match to the end of the paragraph? You could use (?<=\#).+
    for two words use (?<=\#)[\l\u]+\s[\l\u]+
    for a match for both one or two words (two if there are two, otherwise only one), try (?<=\#)[\l\u]+(\s[\l\u]+)? (not tested)

  • Why not there a "Find/replace in Grep style" inside the Para style?

    Whenever I type a digit in my text, it should be colored red as per style. I do this by grep style inside the para style, but now I need to insert brackets before and after of the digit(s), i realize that there is no replace option in grep style in the para style. Why not it be there a "find/replace" instead "find" only as it now appears?

    Ya, this is simple, finding a specific para style with digit and change them, when the book in first pass. But while in the correction pass of the same book, whenever we are inserting more text into the document, there are chances to be unaware of the digit style that, it should be surrounded by brackets, and it happened earlier so I have a thought of it. Again, while paginating a book having more than 350 - 600 pages, and 3 to 4 guys working in it, I think this may work.
    Expecting your valuable comment on this.
    Thangaraj Mohan.

  • GREP - negative look behind

    I should be able to do this, but I am not.
    I want to change the formatting of negative numbers in tables from - to ().
    Fine I can do that (thanks to help from this Forum).
    First I do a Grep find/replace "-(?=.+)" to "("
    Then "\A\(.+\Z" to "$0)"
    Happy
    But now I have negative numbers in cells of different width.
    The numbers must be aligned to the last number, leaving the ")" stick out to the right.
    I can do that by applying a paragraph style which depend of the width of the cell, and letting it left-align to ")"
    A laboriously work.
    Instead I am trying to apply a right indent to all positive number cells not having "()". I can do that manually, but thats no go.
    I thought I could apply the right indent paragraph style like this:
    (?<!$0)\)
    or
    (?<!$0\s)\)
    or perhaps
    (?<!$0!\s)\)
    But no, they all find the actual negative numbers having "()".
    Can you help me how to solve it?
    Best regards
    Nina Storm

    The one which worked for med was:
    "\A[^)]+\Z"
    Hey, that's different than what I had in mind -- but if it works: great!
    Allow me to explain yours: the expression "every single character except a close paren", repeated once or more. I was thinking along these lines:
    \A[^(].*\Z
    -- everything except an opening paren (because I think you typed it wrong in this post ), which 'eats up' the very first character, followed by zero or more 'any characters'.
    These are the basic 'repeat' codes:
    x?   One 'x' or none, as in "Figures?" -- this will match both "Figure" and "Figures"
    x*   Zero 'x'es or more -- this will match the start of "hello" (because there are zero exes!) and "xxxxxxhello"
    x+  One 'x' or more -- this will not match the start of "hello" (because there are zero exes) but will match the start of "xxxxxxhello"
    x{2,5}  Not used very often, but it can be handy: a minimum of 2 and maximum of 5 exes. Won't match 'x' but will match 'xxxx' and the first five exes in 'xxxxxxxxxxxxxx'.
    In addition, all of these 'repeats' will match as many characters as possible; 'x+' will match the entire string 'xxxxxxxxx'. If you don't want that, put another question mark right after the code to match as little as possible: 'x+?' will match only the first 'x' in 'xxxxxxx'. This is important if you are looking for delimiters of any kind, such as a set of open and close parentheses, like this:
    \(.+\)
    This will match everything from the very first opening to the very last closing parentheses in an entire paragraph -- repeating the 'any' character code. Now you wouldn't want that if, for example, you want to replace them with square brackets, so in this particular case you would use
    \(.+?\)
    Oh but I'm digressing.

  • Cannot ping inside IP behind sonicwall from Cisco ASA 5500

    I have a sonicwall at site B and the cisco asa5500 at the main office. (site A)
    The site to site VPN is working, but I can not ping the inside ip (10.1.5.2) of the sonic wall from Site A. I need this only to access the computers behind the sonicwall for remote desktop and dameware.
    I have another office that also has a sonicwall (same config)  and I can ping that inside IP from Site A.
    I can not see why I can ping one site and not the other.
    What needs to be configured on the ASA 5500 to be able to ping inside the sonicwall at site B?
    I prefer the wizard over the CLI.
    Thanks,

    Hi
    AFAIK No you can not make vpn, transparent and routing in the same unit.
    I would not want the DMZ and the outside interface to have overlapping ip address ranges.
    logging and trying to keep track of it all would be way to confusing for me.
    so what I would do is to split the external network into two network units (/25) and move all the units that can be moved to a dmz with rfc1918 addresses.
    The units that can not be moved from the external network would have to stay put "for now" in another dmz with the 190 addresses /25
    This would need the isp to change their routing table in the edge equipment, the lower (or upper) part of 190.X.X.X/25 would be the dmz and needs to be routed to the firewall ip address.
    Then as time passes by the DMZ will be depopulated when equipment is moved out and replaced and in the end you will have the isp to merge the two 190.x.x.x/25 address ranges to one /24 and you will be back to todays setup but with all the servers in a rfc1918 network.
    Do not use NAT, use PAT instead when it comes to the ip addresses translated from the internet side. it makes for a much more secure network and you do not need as much ip addresses (in a normal case)
    With NAT you are translating the whole ip address but with PAT you translate the port so you can have ip X port 25 go to ip Y and port 25 and then you can have ip X port 80 go to ip Z port 80 or maybe 8080 or what ever port you want.
    good luck
    HTH

  • Preview what a background 'Image Repeat' will look like?

    I want to preview some website background images that I have which are 1 pixel wide without having to upload to the website and refresh the page. Is there a way to preview images repeating in either Adobe Bridge or Adobe Photoshop or any product in the Adobe Creative Cloud for that matter without having to upload to the website and refresh the page? I would ideally like to scroll through the images and have it simulate the repeat horizontal style.

    Not sure that is what I'm looking for.
    I have over 2000 different gradients for website backgrounds that I just want to scroll through to pick the one I want but I need the image to repeat horizontally so that I can see it because it's only 1 pixel wide ...
    Ideally, I would like to just be able to hit my arrow key down and down and down and preview what the background would look like super quickly so I can pick the one I like best.
    Hopefully that makes better sense.
    Thanks!
    Something like this website, but where i don't have to upload files to the web.
    http://lab.rails2u.com/bgmaker/

  • Grep script that looks for paragraph style A followed by paragraph style B

    Hello,
    I am fairly new to scripting in Indesign and I have run across something I want to script that I don't know how to do. Two of the paragraph styles that are in our files are Normal and Song. I need to add an extra paragraph return between all instances of Normal followed by a Song. I tried to search the forums to see if this was already on here somewhere and if it is I didn't come across it. I would like to set it up as a grep script but if anyone has an alternative way to do this I would like to know also.
    Thanks in advance

    Hi,
    So you could use a script.
    I assume a text frame with proper story is selected and whole story is in one frame or linked frames.
    myStory = app.selection[0].parentStory;
    if (myStory.constructor.name !== "Story")
         alert ("Select a destination text frame, pls\rand try again");
         exit();
    myNormal = app.activeDocument.paragraphStyles.item("Normal");
    mySong = app.activeDocument.paragraphStyles.item("Song");
    app.findTextPreferences = null;
    app.findTextPreferences.appliedParagraphStyle = mySong;
    mFound = myStory.findText();
    len = mFound.length - 1;
    if (len >= 0)
         while (len--)
         currPara = mFound[len].paragraphs[0];
              if (myStory.paragraphs.previousItem(currPara).appliedParagraphStyle == myNormal)
              currPara.insertionPoints[0].contents = "\r";
    rgds

  • My app store icon for my iPhone5s has disappeared.  Needless to say, I can't add apps without it. suggestions for restoring it?  I looked behind all the other apps

    My app store app has disappeared, not under another icon or in a folder, and siri won't open it.  How to get another?

    It might have been disabled in restriction settings>general>restrictions are make sure App Store is on

  • Why doesn't Grep Styles with pos lookbehind work?

    Hi,
    I've posted another thread but I suppose I expected too much. I'll try to siplify this.
    I have text where I want to catch underlined text:
    Ponny, - Cob…….499,-
    125, - 135, - 145, - 155…….399,-
    140, - 150, - 160, - 170……..99,-
    140, - 150………99,-
    This paragraph grep style works for the above:      ^\w+,\s-\s
    However, when I want to use positive look-behind to just catch the " - " it stops working.
    I have tried the following (none of them catches anything at all):
    ^(?<=\w+,)\s-\s
    (?<=^\w+,)\s-\s
    (?<=\w+,)\s-\s
    Is there a limitation as to what syntax I can use in the lookbehind?
    Pointers anyone?
    /K

    Hi Eugene,
    Lookaheads and Lookbehinds don't work when using the repeat codes, like "+" or "*" or "?" etc.
    I guessed there might be a limitation as to what works.
    Eugene Tyson wrote:
    Can you search for
    \s-\s
    And only search for underlined text in the
    Find Format
    area
    No, sorry. The underline was olnly to indicate what I was trying to grep...
    I don't want to use find-replace. I want to use the paragraph grep style.
    /K

  • GREP Search to apply superscript

    Hi there,
    I'm a longtime InDesign user but I'm pretty new to GREP.
    Currently I'm working on a French document, but this could easily apply to English documents as well.
    I'm trying to use GREP to identify and apply superscript to letters that come after numerals indicating their position (i.e., 1st, 2nd, 3rd, etc.)
    The code that I've written that I "hoped" would do this is:
    (?<=\s\d+)[\l\u]+(?=\s)
    What I hoped this query would do is:
    1 - positive look behind for a white space followed by one or more numbers (?<=\s\d+)
    2 - find any one or more letter characters [\l\u]+
    3 - positive look ahead for a white space
    A sample bit of text that I'm trying this on includes the following text:
    ...dans le cadre du 40e anniversaire...
    My hope was that this would select the "e" which I could then apply superscript to. I can get parts of the code to work individually but I can't get the full query to work.
    If anyone can point me in the right direction to get this working I would really appreciate it.
    Thanks in advance!
    Troy

    Remind me again, what letters get superscripted after a number in French?
    You can use something like this:
    ((?<=\b\d)|(?<=\b\d\d))e\b
    which will pick up "4e" and "40e" -- add more digits in the first OR group, more (single) characters can be added in a character set [like this] instead of just 'e'.
    WhatTheGrep's breakdown:
    (  Begin Group #1
              (?<=  Lookbehind Group
                        \b  Word boundary
                        \d  Any digit (0..9)
              )  End Lookbehind Group
              |  Match previous part OR next part inside Group #1
              (?<=  Lookbehind Group
                        \b  Word boundary
                        \d  Any digit (0..9)
                        \d  Any digit (0..9)
              )  End Lookbehind Group
    )  End Group #1
    e  Literal character “e”
    \b  Word boundary
     (1 (?<=< \b \d <) |1 (?<=< \b \d \d <) 1) e \b

  • More help with GREP needed

    I have been attempting to create some nested styles.
    So far, I am getting the hang of it.
    I have created a grep style that will make all text after the word "NOTE: " into italic. Also, I have grep style that makes all text that is "FIGURE +\d+\d" into bold text.
    The problem I have is that if the word "FIGURE " etc. is in the italicized note text, then it will not become bold.
    For example: "Operate the switch to begin the process (FIGURE 3-3). Make sure guards are closed (refer to FIGURE 3-1)."
    That works fine, and "FIGURE " is bold. However, when I change the sentence by adding "NOTE: Make sure guards... " it all becomes italic, and I loose the bold on "FIGURE 3-1"
    So, is there a way to augment my italic grep with some kind of inclusion... as if I were saying "if "FIGURE +\d+\d" make that is bold italic"
    sorry for the long-winded attempt to describe what I want to do.
    Thanks in advance for help.
    RPP

    RPP,
    The trouble is that in GREP style you can find text but not formatting, so you can't say something like "find FIGURE only when it's italic". In the Find/Change dialog you can, but in GREP styles you can't.
    You also can't say "look for FIGURE if it's preceded by NOTE: and any characters in between". Unfortunately, lookbehind can't cope with variable-length text. So if you always have "NOTE: Refer to FIGURE ...", then you can use lookbehind and you set-up would be this:
    apply italic to FIGURE [-\d]+
    apply bold to NOTE:.+
    apply bold-italic to (?<=NOTE: Refer to )FIGURE [-\d]+
    The first parenthetical is a lookbehind: in this case, FIGURE looks behind, meaning you find FIGURE only when it's preceded by "Note: Refer to", which is not matched itself. So bold italics would be applied only to FIGURE [-\d]+, and only when preceded by ...
    But you're not likely to have such fixed text. When you have just a few alternatives, you can list them as alternatives, so if you always have "Note: Refer to " or "NOTE: See " you could salvage your set-up, but with more than let's say three alternatives it gets messy.
    (?<=NOTE:.+? )FIGURE [-\d]+ , which you would hope would match any text from NOTE: to FIGURE, doesn't work as a lookbehind.
    Peter

  • How do I repeat image 100% height in a box within the template

    I have built a new template that already has a background image behind the content area.  This background image is 100% width and height.  Now I have made the header area, the content area and the footer area.  What I am needing some help with is:  I want to have a box behind the content area that continues into the footer.  In that box I want a repeated background pattern that continues regardless of the amount of content in the content area.  I know how to do this using tables and code, but I can't seem to figure it out in MUSE.  I have added the box, added the repeated verticle image, but it won't expand downward 100% height.  It just stops at the height of the box that was built in MUSE and then the repeated background stops too...  Can someone explain to me how to do this properly?  It's all I have left and then this site template is complete.
    Tom

    Can you elaborate please.  I have built a template (or master page) with this box in it and it starts just below the line of the header and extends to the bottom of the page. It has a repeated verticle image inside it.  What happens though is that I build a page and assign the master to it, add a content box into the page for text and images.  If the content extends downward past the original size of the master page box height, the box will not extend itself with the height needed for the content.  IE:  if the box is 600px high in the master and then the content is 1000 px high, the box will not expand to the 1000 px height and instead stop at the 600 px height.
    Is there a tutorial with this in it somewhere?  I have build numerous MUSE sites both small and large and have yet to do this repeatable background pattern behind just the content area separate from the background image itself.
    Thanks for your help.
    Tom

  • How to (grep) similar words ending or not in s?

    The idea is to recognize identical words like:
    car /cars
    house/houses, etc.
    Could not solve with look-behinds, etc.

    We are working in an interactive grammar (spanish) where practically all the words, at least for our project, form plural with the addition of letter s. (Spanish do not have double ss ending words). Working with plurals is part of the goals.
    The copy is a list (single words separated by hard returns already alfabetized):
    Dardo
    DardoS
    Dedo
    DedoS
    Día
    DíaS
    Duda
    DudaS
    It is required that grep identify the singular or the plural when both words are the same.
    (Some exceptions like the word Dios/Dioses= God will be resolved  by other means)
    Thank you!

  • 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

Maybe you are looking for

  • HT201335 Mirroring function on Apple TV 3gen not working - help please

    I have a brand new Mac Book Air and recentlypurchased the Apple TV (3rd gen). The mirroring icon worked until I closed the screen on the laptop and then Apple TV stopped working on the tv I was streaming content to. I opened the screen and since then

  • Update Script Problem CS2 to CS3 ( Time/Date/Year Script NOT WORKING IN CS3?

    The below script works in CS2 but not in CS3? WHY? //DESCRIPTION: Use to insert date/time into document. if (app.documents.length == 0) { exit() } insertDTs(app.documents[0]); function insertDTs(aDoc) { var curPrefs = aDoc.characterStyles[0].extractL

  • Updating of TestStand data from CVI Callback

    How do I update the variables in TestStand from a callback function in LabWindows. In the attached file the use must press the pass or fail button. This action is received in the callback function in CVI where I call the TS_PropertySetValBoolean meth

  • Web.Xml Mapping For using Filters in Servlets

    Hi Team Can any one help me in getting the correct xml mappiing for using filters Currently i am getting 404 error when calling any resource using the below mapping <web-app> <display-name>OM</display-name> <welcome-file-list> <welcome-file>Hello.htm

  • XML Standard for UI Definition

    Hi! I have to implement an engine that will convert one (or more) XML files based on XSD into Java objects to display a (rather complex) user interface in an Java standalone application. Before I start, I would like to know if there are XML standards