Attempting to create a GREP Style

I'm trying to make a GREP style for one of my paragraph styles, that will take the text from the beginning of a line until a colon and set a character style to it to bold that part.
Example:
Step 1: Take bread
Step 2: Take peanut butter
Step 3: Spread peanut butter on bread
I don't think I've been getting the syntax right.  I've put ^\:~h and ^:~h into the 'to text' box, thinking this meant "Beginning of line until the character ':' and end" but neither of those have given me the results I want.  Thanks in advance for the help!

Prismatus wrote:
Your response worked for me.  I had tried using a wildcard before the ones I posted, but only put the . in, assuming it would cover more than just one character.  I assume the +? covers all characters until the colon shows up, yes?
No, it's slightly more complicated than that (sorry!). By default, GREP is Greedy -- that means, if you use this
^.+:
GREP will think that the Any Character wildcard may be repeated as much as possible (that's the '+') before it needs to match the colon. What this means is that it will work just as you expected for
Step 1: This is a single line.
but will go out of its mind with this
Step 2: what will happen now? Well, contrary to what you were expecting, the entire line will be marked bold, all because everything up to the very last : will be matched!
The bold bits accurately shows what happens! Another example would be this:
\d+
which for a string of "123" will not match just the first digit, then the second, then the third, but all of them in a single long go. By default, GREP will grab as much as it possibly can.
Adding a question mark behind the "Repeat Me" character reverts this behavior to Non-Greedy behavior, and as such GREP will match as little as humanly possible:
\d+?
will then match just the "1" in "123".
Prismatus wrote:
I also like the be literal part, but I was wondering what you would have instead of \d if you had more than nine steps, or if you had substeps (1a, 1b, etc.).
That's just a case of adding more specifiers. To match one or more digits, you need this:
^Step \d+:
The '+', again, will allow a repetition of the "digit" code. In this case you don't have to add a question mark, because there is no way this could run out of control; first, it will only match digits, and second, these digits must be followed by a colon.
And if you may or may not have a single lowercase character following the digit (but still before the colon), you'd use the Any Lowercase Character code and the Zero or Once repetition specifier:
^Step \d+\l?:
(that's a lowercase ell.) You see the question mark meaning Something Entirely Different here? It's only a Non-Greedy marker when immediately following another repetition code, one of these
* (zero or more)
+ (once or more)
? (zero or once)
{4,8} (or any other set of numbers -- this is at least 4 and at most 8 times)
Uh, by the way, that makes this
abc??
a valid GREP. It will match "ab" or "abc", and then always select the shortest possible match of these two, which is then the "ab" one. ... Uh. I'm pretty sure this may be useful, some time in the future.

Similar Messages

  • Create a GREP-Style with script? [AS] [CS4]

    Hi
    I'm trying to ad a grep-style to a paragraph style.
    It's easy to read/write properties from one that already exists but how can I create a new one?
    This is in applescript, CS4
    rgds /Mattias

    Yep, know about Nested Grep Style.
    In AS it:s http://www.indesignscriptingreference.com/CS4/AppleScript/nested-grep-style.htm
    If I have a P-style in a document, with a nested grep style applied. I can read and write to that grep style by calling it:
    nested grep style 1 of paragraph style "myParaStyle"
    read: grep expression of ... -- -- -- -- -- -- -- Where ... is the above line
    write: set grep expression of ... to "xyz"
    However, if the P-style doesn't have a nested grep style applied, I can't find a way to create/insert one into the P-style.

  • Can somebody please help me creating a GREP style to reformat all the website adresses in my layout?

    i've got this text from a client full with webadresses, some end with .com or .nl and i would like to highlight these adressess in bold and blue... i created a textstyle for it but the only thing i manage to get as a result is only the beginning of the website 'www.' i know it's possible but my skills are lacking in this departement...
    can anyone help me getting started...?

    Got it.
    parentheses group #1 (the first | separated OR group): DOS path name, because a link can also refer to a file.
    parentheses groups #2-5 (2nd OR group): e-mail address. Note: a "mailto://" prefix does not get matched here.
    parentheses groups #6-13 (3rd OR group): URL, with a mandatory prefix "http://", "https://", "ftp://", and some more ("smb://", for example, is a Samba server file prefix). This also includes "ftps://", which was unknown to me but it appears it's perfectly valid.
    It does not match the "mailto://" prefix for an e-mail address, but that's a moot point because the URL may not contain a @ character anyway.
    This group correctly recognizes URLs that contain one or more hyphens in the base name (it also correctly rejects hyphens in the domain extension).
    parentheses groups #14-15: (4th and last OR group): any non-prefixed URL, recognized solely on the basis of "any sequence of word characters, including the hyphen, followed by a period, optionally followed by some more characters (including both period and forward slash but excluding the hyphen), followed by at least two uppercase or lowercase letters.
    This last one is responsible for (a) recognizing both "deadline.com" and "keefe-studios.com" as URLs, but (b) also rejecting "www.test-test.com" -- a hyphen in the 'center', fully optional, part.
    Interestingly, there are more differences between the more exact 'match only with prefix' and the catch-all 'match about anything'. The former includes among the allowed characters: ':' (which, if I recall correctly, is only valid if a port number follows!), '#', '$', '%', '&', '?' and '+', so it matches a server query as well:
    http://www.google.com/search?hl=enl&tbo=d&site=&source=hp&q=allowed+characters+in+url&oq=a llowed+characters+in+url
    The latter does not include all of these characters, just letters, numbers, the hyphen (but not in all positions), and a period. It's probably because this is an unreliable way to match URLs after all -- hence the number of 'false hits'. These would only increase with even more allowed characters.
    Lesson learned: to be assured "Create Hyperlinks Automatically" works as expected, make sure URLs are prefixed with "http://", and mail addresses are not prefixed with "mailto://". I didn't test if the function actually creates a correct e-mail link, but even if it does the prefix is not included in the clickable linked text.
    (Also interestingly, it appears a GREP style, fed with this same query, doesn't stumble over the hyphen whereas a GREP find does. I don't think I'm capable of figuring that one out.)

  • Creating a GREP style Help Needed

    I would like to set-up a style using GREP expression(s) that would do the following:
    Everything preceding an em dash (including the em dash and two spaces after the em dash) would be set to bold-italic, AND everything in the paragraph that begins with the word "NOTE:" until the end of the paragraph would be regular-italic.
    Here is a sample of the kind of text I want to format with one style:
    OPERATOR PANEL - The operator panel is located on the right-hand electrical enclosure. NOTE: Not all equipment will have the same operator panel. Refer to schematics for additional information.
    "OPERATOR PANEL - " would be all bold (or bold italic). The body text is regular. the "NOTE: Not all .... " to the end would be regular-italic.
    Any help or direction to a web-site with examples would be appreciated.
    Thanks in advance.
    RPP

    It's easier than you think.
    Peter's suggestion of a regular nesting style might work, except that it's
    i always
    applied to each paragraph you apply it to. That's just what the Grep styles are for:
    i conditional
    stuff.
    The 1st half: Apply Style: Bolded To Text: ^.*? ~=
    (there should be another space after the '=')
    The 2nd half: Apply Style: Italicized To Text: NOTE:.*$
    These are both pretty much basic GREP expressions -- except for the "~=", that's Adobe's --, so just about any google to a GREP repository can explain them. I already knew the basics, but
    this page taught me some new tricks.

  • IDCS5/MAC - GREP Style to uppercase a letter after a dash between words

    G'day there.
    I'm trying to create a GREP style to uppercase a letter after a dash between words, more specifically where one word starts with a capital and the one after a dash does not e.g. Lorem-ipsum = Lorem-Ipsum
    The full story is that there is a standing indesign file used over and over again which data-merges surnames which are in a massive database. The data arrives in uppercase and our mail barcoding software allows us to Title Case certain fields, but the Title Case behaviour has the following results:
    * McLeod = Mcleod
    * D'Agostino = D'agostino
    * Smith-Bunting = Smith-bunting
    i've been able to solve the McLeod = Mcleod problem with the following GREP style:
    (?<=Mc)\l
    and then apply a character style which is nothing more than All Caps.
    similarly, i've been able to solve the D'Agostino = D'agostino problem:
    (?<=\u')\l
    and once again apply the All Caps style to the affected letter. This also solves the O'leary problem to O'Leary.
    However, when I try these GREPs to grab the Smith-bunting style issues:
    (?<=\u\l+?-)\l     or   (?<=\u\l{2,}-)\l
    the search won't work, nor will it work with regular Find/Change GREP replace... yet the expression \u\l+?-\l will find the block that i'm after.
    I could use the search
    (?<=\l-)\l
    and this will find Smith-bunting = Smith-Bunting... but will also find co-operate = co-Operate (will find two words joined with a dash but  starts with a lower case letter).
    This is fine if the para style is applied to the  line in the address block containing the client's name, but if the name is referred to in a block of text, then that block of text has to have the para style with the GREP style applied, and any dashes between words in that para behave the same way as the name.
    yes, it is possible to go into excel and use the =PROPER(affected cell) and fix the Smith-Bunting fields, but i'm trying to create a solution which will work solely in InDesign so that other operators in the office (who aren't familiar with excel) can simply open the standing file and dump in the txt database generated by the mail barcoding software.
    there are other names that the mail barcoding's title-case fouls up i.e.
    * MacLeod = Macleod
    * van der Graaf = Van Der Graaf
    * van Diemen = Van Diemen
    but a GREP to make Macleod become MacLeod may foul up Mack, Mackie or Macy to become MacK, MacKie or MacY.
    I also know that a GREP for the van der or van won't work as the style will only force letters to become All Caps, not uppercase to lower...
    Ultimately...
    does anyone know a way to GREP style (not a find/change GREP) a fix for Xxxxx-xxxxx = Xxxxx-Xxxxx?
    Colly
    Colecandoo.

    I agree with Haakenlid on his Dirty-Workaround view -- I feel data should be entered the way it oguht to, not altered by some magic GREP styling -- but then again I can also sympathize with your POV re: a fire-and-forget solution even your dumbest operator can't miss.
    Oh the rigors of life.
    If you are totally, absolutely certain you want to do this by GREP, use this:
    (a) Set a To Capitals character style to the string
    \b\u\l+\-\l
    -- this will magically transform "Hon. Lt. Sir John Forsythe Blunt-object" into "BLUNT-Object".
    (b) Then override ( ! ) the first half again with another character style that removes the To Capitals attribute ( ! ):
    \b\u\l+-(?=\l)
    Notice how this expression is exactly the same as the above one, except for the very last code -- the next lowercase must also be caught, but now using a lookahead so its formatting won't be affected.
    This removes the All Caps override from the first halve, changing it from "BLUNT-Object" back to "Blunt-Object".
    Lots of side effects, I'm sure. Perhaps it is safer to teach your operators to run a single script.

  • How can I apply a GREP style to a text variable?

    Hello everybody,
    I have a question concerning GREP styles inside Paragraph styles.
    1. I've created a text variable to generate a recurring title on the upper side of the page based on the main title paragraph style;
    2. The recurring title is in Adobe Garamond Small Caps, all letters in lower case, and it is formatted with a paragraph style sheet in the master page;
    3. I want to create a GREP style for the recurring title, according to which every time that in the recurring title appear an apostrophe or the double quotes, they are automatically lowered 2pt on the baseline
    (I already created the character style sheet that lowers letters of 2pt).
    What I need is the correct GREP formula to automatically apply the character style sheet to apostrophes and double quotes, in the line of text generated by the text variable...
    Thanks for your  help
    p.

    Hi,
    As I said, using Power Headers is the best way to do it.
    As Power Headers treats the header as "live text", you can use a simple grep style inserted in the header para style:
    … to obtain:
    For the sample, I use a char style named "-2pts" with Shift -5 pts and Green color to show you the place of ' and ".
    Don't forget that, even Power Headers treats the header as "live text", you only have to update Power Headers to make an update of the headers! 
    Even I use in another cases Tomaxxi's [JS] and it's a good way to treat the question, Jean-Claude Tremblay's solution is less interesting because the variable used is converted in text. If the variable text content changes, it's more complicated to manage the update!

  • GREP style as part of paragraph style

    I'm wanting to create a GREP style that uses a character style. Whenever certain words (No class) appear followed by dates. Sometimes it is a single date and sometimes more than one date. For example:
    No class 7/11.
    No class 7/11-8/11.
    What I have so far is:
    No class \d+.
    This works okay through the words "No class" and the first digit, but not for the whole sentence. I've tried different combinations but nothing that works correctly.
    Can anyone help?

    Peter,
    I so much appreciate your help with this. Your explanation makes it understandable. But there is still a mystery.
    The GREP for Instructor: Instructor Name works fine. The GREP for the date sentence is not working. Instead of the date sentence becoming italic, it  matches the first part of the paragraph. This is what the GREP looks like:
    This is what the paragraph looks like with the GREP applied:
    It should look like this:
    In a separate issue in another paragraph, which is a heading paragraph, I have a similar situation. The headings are bold, some headings list ages, and some list ages AND whether parental participation is required. I thought I could extrapolate from the information you've given me to fix this paragraph as well. I've tried different combinations, but so far haven't gotten it to work. The paragraph looks like this:
    But it needs to look like this (bold paragraph with ages in regular,and parent requirement in italic):
    The heading doesn't always have an age requirement, and doesn't always require parental participation.
    The catalog is quite long, so if there is a way to fix these two types of paragraphs, it would save a ton of time.

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

  • Use Grep Styles to add multiplication symbol.

    Hey Everyone,
    Has anyone used grep styles to change 5x6 to 5×6?  I tried to do it, but the dialog box to create a grep style is the character style dialog box. But, I am unable to enter a glyph. Now, I can use the find and search for \d+x\d+, but it will find 5x6 and change it all to × instead of changing the "x" only. I would hate to have to search for "x" in a document. Just trying to find a way to change "number 'x' number" to "number '×' number."
    Thanks,

    Or you can use (?<=\d)x(?=\d)  [that's a look-behind/lookahead withthe x in the middle] and apply a character style to scale and shift the x. GREP styles cannot change the glyph used, only the formatting.

  • Nested Line Style affecting my GREP style

    Hello all.
    I'm formatting a large book at the moment and am trying out a "runt fixer" to prevent bad sentence breaks in columns. So far I have created a character style that only applies the "no-break" attribute, and have two GREP styles - one looking for a space and 8 characters or less before a full-stop, exclamation mark or question mark; and another looking for the 8 characters or less then a space after a full-stop, exclamation point or question mark. The codes are:
    \s.{1,8}[.!?]
    and
    (?<=[.?!]\s).{1,8}\s
    It works... nearly. It has issues when fullstops are used in numbers such as displaying currency, dates... but largely works for the text.
    The problem occurs when I go to the Drop Caps and Nested Styles feature, and use the "New Line Style" - in this instance it was used at the beginning of chapters to make the first line smallcaps. Instead, something strange happened to the second GREP style - it no longer worked.
    In case I'm not explaining myself properly, i've uploaded a sample of what is going on here: https://dl.dropboxusercontent.com/u/55743036/runt-issue.idml
    The first page is OK, but the second page displays the fault. I've colorised the GREPs so that it is clear what is not breaking at the end of a sentence and what is not breaking at the start of a sentence.
    Has anyone experienced this before or can tell me what is going on? it is my error or is it a bug?
    Colin

    @Colin – I thought, I could make it work, if I introduce another GREP Style BEFORE the one that is not working: A GREP Style, that is doing nothing (applying the character style "[None]" to a character like "§" that is simply not in the text. Did not work.
    Another attempt with InDesign CS5.5 OSX 10.6.8: I made a new paragraph style BASED ON the one that is not working. Changed nothing in that new one, just let it be based on the not working one.
    Now: THAT IS FINALLY WORKING! But in a different way I expected…
    "Will work" is based on "not working".
    Here all GREP Styles used in "Will work":
    Uwe

  • How can you create a paragraph style that removes all spaces and forces everything to lower case?

    Hi,
    Is there anyway of using GREP (or some other magical wizardry) to create a paragraph style that automatically removes all spaces and forces words into lower case?
    Strange request i know....I'm wanting to use it for datamerged email addresses.
    Thanks

    so doing it through InDesign is a work around I'm exploring.
    Excel has the 'LOWER' function and the ability to record macros for a quick find/replace on the spaces - so that's definitely a good option if it can't be solved purely in InDesign.
    You can change case via scripting in InDesign. This AppleScript (OSX only) will set the case of the selected paragraph style to lower. It would be possible to add some code that would strip spaces as well:
    tell application "Adobe InDesign CS6"
        activate
            set StyleList to name of every paragraph style of active document
        set myDialog to make dialog with properties {name:"Document Paragraph Styles"}
        tell myDialog
            tell (make dialog column)
                tell (make border panel)
                    tell (make dialog column)
                        make static text with properties {static label:"Choose a Style", min width:150}
                    end tell
                    tell (make dialog column)
                        set myPresetsDropdown to make dropdown with properties {string list:StyleList, selected index:0, min width:150}
                    end tell
                end tell
            end tell
        end tell
        set myResult to show myDialog
        if myResult = true then
            --+1 gets the correct name because list starts at 0
            set myStyle to item ((selected index of myPresetsDropdown) + 1) of StyleList
        else
            return
        end if
        destroy myDialog
        tell active document
            set myStyle to paragraph style myStyle
            repeat with j from 1 to (count stories)
                repeat with i from 1 to (count paragraphs in story j)
                    if applied paragraph style of paragraph i of story j is myStyle then
                        --defines a variable to replace the generic this_text parameter in the handler
                        set SCText to the contents of paragraph i of story j
                        set contents of paragraph i of story j to my change_case_of(SCText)
                    end if
                end repeat
            end repeat
        end tell
    end tell
    on change_case_of(this_text)
        set the_comparison_string to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        set the_source_string to "abcdefghijklmnopqrstuvwxyz"
        set the_new_text to ""
        repeat with thisChar in this_text
            set x to the offset of thisChar in the_comparison_string
            if x is not 0 then
                set the_new_text to (the_new_text & character x of the_source_string) as string
            else
                set the_new_text to (the_new_text & thisChar) as string
            end if
        end repeat
        return the_new_text
    end change_case_of

  • A GREP style not holding in CS4

    Hi,
    OK...I have been playing with a bunch of these GREP searches in CS4 where I can put them in as a stylesheet.
    I have a character style that is called superscript, that automatically makes a ® superscript when it is typed, and that is working fine.
    Then I added my lookahead for any TM or ® to add a 100 tracking in between the letter and the tm or ®. It does it if I have the type in the box and apply my style to the whole box. But, if I go in and make changes to the text, the ®-superscript automatically happens when I type a new one, but the tracking doesn't automatically happen. What's worse is, if I select the text and try to apply the style manually, it still doesn't not apply the 100 tracking. I have to make it a basic or none style and then re-apply the good one.
    If it is in the GREP style of the paragraph style, shouldn't it do it dynamically?
    Here is my image.
    thanks!!
    babs

    The only object I know of you can create an InDesign and specify whether it prints or not in the PDF is a button. That would definitely NOT work with character styles.

  • Completed a project in iMovie which is 41 minutes long (2 GB) . When I attempt to  create a iDVD disk(via clicking on share) ,I am advised that an error occurred because the project is too long. Have made other movies/created disks that are longer than 41

    Have completed a project in project library that is 41 minutes long ( 2.1 GB ) . When I click share and attempt to create an iDVD disk , an error notice appears claiming the new project is too long.  Have created other iMovie/DVD disks in the past which were longer than 41 minutes.  What corrections do I need to make to ensure I can create  a DVD disk for this 41 minute ( 2 GB ) project... I am using a 17 MacBook pro for this project.

    PS - have found other posts indicating that clips smaller than 2s or sometimes 5s, or "short files" can cause this. Modern style editing often uses short takes ! Good grief I cannot believe Apple. Well I deleted a half a dozen short sections and can export, but now of course the video is a ruined piiece of junk and I need to re-do the whole thing, the sound etc. which is basically taking as much time as the original. And each time I re-do it I risk again this lovely error -50 and again trying to figure out what thing bugs it via trial and error instead of a REASONABLE ERROR MESSAGE POINTING TO THE CLIP IT CAN'T PROCESS. What a mess. I HATE this iMovie application - full of BUGS BUGS BUGS which Apple will not fix obviously, since I had this product for a few years and see just hundreds of hits on Google about this error with disappointed users. Such junk I cannot believe I paid money for it and Apple does not support it with fixes !!!
    If anyone knows of a GOOD reasonably priced video editing program NOT from APPLE I am still looking for suggestions. I want to do more video in future, but obviously NOT with iMovie !!!

  • GREP Styles and Changing Ligatures

    Hello,
    I have been using InDesign since it came out, and have great results. However, I am brand new to GREP, and was wondering if a script could be made/written(?) by me (a person who does not understand script), to do the following:
    I have tons of copy, regularly, with a number of different ligatures in it. One (of the many, the fi ligature) causes the client to cringe. Is it possible to change this ligature by - turning off - the fi ligature only? Because I am out of the old school, I appreciate ligatures, and tight kerning.
    I realize, I could just turn off ligatures, but, would rather not.
    Thank you,
    Lain Kennedy

    A character style whose only property is no ligature, used as a GREP nested paragraph style, is certainly the best approach. However, if the ligature appears in many different paragraph styles, it might be possible to change them all in one operation by creating a paragraph style that duplicates (not based on) [No Style] - that is with no properties set - and create a GREP nested style for it that applies the no ligature property to fi. Then set each paragraph style to be based on this no-fi-ligature paragraph style.
    I haven't tested this to see if this really works. Character styles are supposed to supersede paragraph styles, but perhaps not in this scenario.
    HTH
    Regards,
    Peter Gold
    KnowHow ProServices

  • Inserting a special character with GREP styles

    Hi.
    I wanna define a GREP style that makes this: if I write Bluetooth I wanna that a registered trademark is added at the end of the word but with superscript format. Is it possible?
    Thanks in advance.

    No, GREP styles only apply formatting, they cannot insert characters. Use a regular find & change to do so.
    (There is a thinking-outside-of-the-box solution. If you have access to a font creating utility, you can create a character 'h' with TM attached to it. Then you can use a GREP style to automatically apply this custom font to just the 'h' of 'Bluetooth'. See http://indesignsecrets.com/insert-a-special-character-with-grep-styles.php.)

Maybe you are looking for

  • Cannot log in to Windows 8.1 Pro virtual machine!

    Hello. I installed Windows 7 Ultimate on my iMac (Mid 2011) via Boot Camp, then I installed Parallels Desktop 8 and my Windows virtual machine was recognised by PD8. Then I upgraded my Windows version to Windows 8 Pro and added Windows Media Centre.

  • How to download a file from other server using servlet

    Hi All.... Good Morning.... right now,i am facing a problem..i am trying to download a file which is in other server..i tried somany ways and i couldnt succeed in this... will u pls give me solution for this.. because it is very urgent for me... i am

  • Issues in importing TR

    HI All, There is an issue in tranporting TR from BW quality to BW production. I modified a query in BW development and transported the TR to quality. There was no error. But while transporting the same TR from quality to production there is an error

  • Firefox does not add info to gmail signin...

    Works with other remembered sign in's. Does not ask if sign in/password should be saved.

  • Journal Entries

    Hello i am recently got a job and facing some problem in understanding the logic behind the job.: Please help me with following query 1) What would be the journal entry for goods transfered to sperate location in SAP for damage and destory? When we g