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.

Similar Messages

  • 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)

  • 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.

  • My screen picture has a negative look to it. How do I change it back to normal? I think I brushed some keys at the same time

    Can someone please help me? My screen has a "negative" look to it because I think I brushed some keys w/my fingers at the same time & made it change & I don't know how to change it back & I've tried looking everywhere but can't find anything that shows me how to change it back. I also have Windows Parallels (a Virtual Machine) & it's doing the same thing on the Parallels side, too.

    Try ctrl + opt + cmd + 8

  • Photos on my ipad mini have a 'photo negative' look

    have recently purchased a mini ipad.  somehow in the process of installing various software, the photos uploaded and newly taken all have a ''photo negative' look.  how do we restore the photos to their normal state?

    seventy one wrote:
    Ah, yes, the ipad equivalent.  I missed the ipad reference (one of those days).
    That's usually my excuse.... That, or lack of coffee.  

  • My screen on my iPad has gone weird flickering colour and negative look about it

    My screen on my iPad has gone weird flickering colour and negative look about it any ideas

    Settings>General>Accessibility>Invert Colors>Off

  • 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.

  • Grep output looks odd or has typos

    Is there a grep maintenance group? I did not find any contact info in the man page for grep.
    I was playing with grep and got the following:
    #and hte coment after is ignored.
    #You can also use a comment ot "disable"

    my bad, please ignore.

  • 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

  • Grep Styles - Conflicting - "^" not working in lookbehind and more

    Hi,
    Still fighting my way in the jungle of paragraph grep styles.
    In InDesign CS5 by the way.
    I import text from DB and they all come in the same.
    I need to use the same paragraph style to all paragraphs.
    I really don't want to use find-change since that would mess up the xml holding the data.
    Example-text explanation:
    • All sizes are separated by ", - "
    • …… = tab
    • Not all rows have tab
    • Sizes can be both numeric, letters, contain "/" and "-" and """ and " " (space) and yes indeed a "," comma!! (and every other idiotic combination you culd think of.)
    • When only 2 posts in a row - should be separated by a ", " = (Comma-space)
    • When more than 2 posts i a row - all posts but first and last should be hidden and separated by " - " (space-dash-space)
    I have tried numerous combinations to get them all but they always conflict with each other.
    Bugger!
    I really shouldn't be impossible.
    Is it possible in Paragraph grep styles to "catch" "any character but these" and kind of make a character-set like [!not this character]   (= [!a|b|c]  )
    Is it possible to count the number of posts in a row? ( like... if more than 2 then hide...bla bla)
    All sizes are separated by the same ", - " and sometimes I want to hide them, and somtimes I want to use one of them...
    Is there any kind of "if-else" thing that can be used??
    My original idea was to be able to catch them by using ^-combinations for beginning of paragraph and matching with tha linebreak and tab but it seems as if that don't always work when using positive or negative look-behind-ahead.
    Oh, I'm blabbering. Sorry.
    Any hints or pointers would be greatly appreciated.
    /K
    A) Got this - Original text
    Same text but this is my Goal!
    134/140, - 146/152, - 158/164……….299,-
    134/140, - 146/152……….299,-
    38, - 40, - 42, - 44, - 46……….399,-
    38, - 40……….399,-
    XS, - S, - M, - L, - XL……….399,-
    XS, - S, - M, - L
    XS, - M
    XS, - S, - M, - L, - XL……….399,-
    B 70, - 75, - 80, - 90, - 95……….199,-
    B 70, - 75……….199,-
    Medium-Wide 17”, - 17,5”……….995,-
    Normal, - X-Wide……….999,-
    16 mm 95, - 105, - 115, - 125, - 135, - 145…......99,-
    16 mm 95, - 105……....99,-
    134/140 - 158/164……….299,-
    134/140, 146/152……….299,-
    38 - 46……….399,-
    38, 40……….399,-
    XS - XL……….399,-
    XS - L
    XS, M
    XS - XL……….399,-
    B 70 - 95……….199,-
    B 70, 75……….199,-
    Medium-Wide 17”, 17,5”……….995,-
    Normal, X-Wide……….999,-
    16 mm 95 - 145…......99,-
    16 mm 95, 105……....99,-
    GrepStyle
    Result wanted
    ,\s(?<=,\s)-\s.+(?=\s-)
    Red undelined text will be hidden
    (Got this)
    134/140, - 146/152, - 158/164……….299,-
    134/140, - 146/152……….299,-
    38, - 40, - 42, - 44, - 46……….399,-
    38, - 40……….399,-
    XS, - S, - M, - L, - XL……….399,-
    XS, - S, - M, - L
    XS, - M
    XS, - S, - M, - L, - XL……….399,-
    B 70, - 75, - 80, - 90, - 95……….199,-
    B 70, - 75……….199,-
    Medium-Wide 17”, - 17,5”……….995,-
    Normal, - X-Wide……….999,-
    16 mm 95, - 105, - 115, - 125, - 135, - 145…......99,-
    16 mm 95, - 105……....99,-
    Need this to not conflict with other grep
    blue underlined text needs to be hidden.
    134/140, - 146/152, - 158/164……….299,-
    134/140, - 146/152……….299,-
    38, - 40, - 42, - 44, - 46……….399,-
    38, - 40……….399,-
    XS, - S, - M, - L, - XL……….399,-
    XS, - S, - M, - L
    XS, - M
    XS, - S, - M, - L, - XL……….399,-
    B 70, - 75, - 80, - 90, - 95……….199,-
    B 70, - 75……….199,-
    Medium-Wide 17”, - 17,5”……….995,-
    Normal, - X-Wide……….999,-
    16 mm 95, - 105, - 115, - 125, - 135, - 145…......99,-
    16 mm 95, - 105……....99,-

    There are error messages in the errorconsole.<br>
    Firefox ignores the css rules because there is a syntax error at line 18:<br>
    -->> table.heading {{background-image:url('barline.jpg');<br>
    please remove one of the opening brackets here<br>
    You can go to Mozilla Developer Network to learn CSS.<br>
    https://developer.mozilla.org/en-US/learn/css<br>

  • GREP - Exclude Period from Selection

    Hello,
    I have been fighting with an expression for a while now. I have a document that formatted poorly when being pasted into InDesign, with every line ending in a carriage return. I am trying to find an expression that selects all carriage returns except those preceded by a period.
    The image above illustrates what I am trying to select. I am unfortunately still fairly new to GREP, but have attempted a few expressions, none of which have wanted to cooperate.
    [^\.]~b will successfully ignore the period, however, also results in it selecting the previous character:
    If anyone may be able to provide assistance on the correct expression to use, it would be very much appreciated.
    Thank you.

    Use a negative look-behind instead: (?<!\.)~b
    Keep in mind that there other punctuation marks that can end a paragraph, so this is not guaranteed not to fail. You might do better to find ([\.\?'")!\s])(~b) and replace with $1

  • Further help with regex

    Hi,
    I want to detect the presence of "fromCharCode" in a String.
    But only when it is not preceded by "String." and not followed by "(34)".
    I have already managed to do the "String." with this regex: (?<!string\.)fromCharCode --> uses the negative look behind
    This will detect the "fromCharCode", but not when it is preceded by "String.".
    But I don't know how to do the "(34)" ?
    Can somebody help me with this?

    thanks, but the problem with this regex now is that "fromCharCode" is not detected in the String fromCharCode(34) and the String String.fromCharCode.
    The text "fromCharCode" must only be detected when not preceded by "String." AND not followed by "(34)".
    Can you do this?

  • Monitor looks negative? Help!

    My wife was letting our 1 year old hit the keyboard on the iMac. Now the display has this "negative" colorless look to hit. Is there some sort of setting that causes this? Some kind of keystroke combination?
    The display settings are set to millions of colors in the preferences. She tried rebooting and the display comes up as normal then quickly inverts to this negative look. Any ideas?
    Thanks for any help!
    -B

    All fixed...
    It was the Accessibility / Vision that got changed
    -B

  • The appearance has gone into a "negative print" look for all windows, web, pictures etc. No changes were made to settings.

    15" MacBook Pro from 2008.
    Working fine this morning and then shut the screen. After lifting 30 mins later the appearnce has all gone in to "negative" style. Have tried shutting down and restarting but with no change. I have tried changing appearance settings. No luck.
    On startup all colours look normal and then it switched to a negative look. I also checked for updates and there were some so I ran them. Interestingly when running the update the background was standard Mac "space" and all colours were correct. That suggests to me that the screen is OK but something is telling it wrong color instructions (sometimes).
    All other functions seem to be working ok.
    Can't attach a screen shot using Grab because this chat says throws up an error - "content not allowed". Its a tiff file?
    Any suggestions welcome.
    Rob.

    Go to System Preferences>Accessibility and make sure that "invert colors" is not turned on:
    It won't show up in a screenshot...
    Clinton

  • 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

Maybe you are looking for