Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

2 More bits of GREP that are vexxing me

Return to Member Forum

  • Author
    Posts
    • #53902
      Anonymous
      Inactive

      Ok, you guys have already helped me immensely with formatting some of my more complicated GREP that I've thrown at you, so i thought i'd see if you'd try your hand at 2 more that i'm trying to write that have me blocked.

      Example:

      Size (waist/inseam): (06)brown 30 32 34 36/30 32 34 36/32 30 32 34 36 38/34, (10)navy 30 32 34 36/30 32 34 36/32 30 32 34 36 38/34

      and so forth. i've got a code for the (waist/inseam) part, what i'm looking for is a part that will bold the numbers you see listed ONLY in paragraphs that contain the (…/…) pattern as well. what i started with is something like:

      (?<=(.+?/.+)dd but i don't even have a clue where to go from there

      2nd problem:

      Inseam Regular 30″ Long 32″ X-Long 34″.

      I want to look for a sentence that starts with Inseam, and bold every word in that sentence that precedes a number. Any ideas?

      Also, looking for a GREP find/change to search for any lower case letters at the beginning of a paragraph and change them to uppercase. can this be done? Another i'd like to add is to find any formatting that's not a char or paragraph style and clear it. Lastly, i'd like to construct a grep find/change for any spaces or returns at the end of the story and remove those. Once again, thanks so much for your help.

    • #53908
      Casey
      Participant

      To get you started this should find any non-whitespace characters followed by a space then any number of digits and only format the non-white space characters…

      S+ (?=d+) and apply a grep style

      In the case of finding all the lowercase letters at the beginning of a paragraph, and converting them to another case, you could use a workaround like All Caps

      ^[[:lower]] and apply a grep style that is formatted to All Caps for it's character style. Not perfect, but meh… ;)

      I'm not a pro like some of these other guys, just another head.

    • #53909

      Hi,

      @Jessereko

      Just one think (I have no time now) : in a lookbehind, the length of the string must be fixed. What is why you can't use + ? *

      I come back

    • #53911

      Lastly, i'd like to construct a grep find/change for any spaces or returns at the end of the story and remove those. Once again, thanks so much for your help.

      Ah — fortunately, that's an easy one. Z is an (undocumented?) Tag-End-of-Story — A is its Beginning-of-Story equivalent.

      This ought to work:

      [rt ~S~s]+Z

      (Replace with nothing.)

      This looks for, and removes, series of Paragraph return, Tab, Space, Non-Breaking Space, and Non-Breaking Fixed Width Space (one of the latter two may have been imported via Word).

      (An additional note: GREP cannot change the case of letters. Use the To-Caps function as Casey said, which will add an text attribute, or just search for it with GREP and change manually. For cases like this I assigned hotkeys to the To-Uppercase and To-Lowercase menu items.)

    • #53912
      Anonymous
      Inactive

      For the example you posted I came up with this

      d+[^/]( +d+)+(?=/)|(?<=[/])(d+[^/])+(?=[[:punct:]])|(?<=/)d+

      I'm sure a lot of it is redundant, it's basically 3 search patterns to find the numbers you have in your example.

      Hope it helps? I'm no GREP expert, but perhaps one of the gurus can tidy it up, or even offer a better solution?

    • #53922

      Hi. I am come back (too late ?)
      Some others regular expressions for examples :

      ^l for any lower case letters at the beginning of a paragraph. I don't know other solutions to uppercase than Casey D and Jongware (perhaps by changing this Peter Kahrel's JavaScript ? https://creativepro.com/con&#8230;..tility.php or using this script : https://indesigning.net/search-&#8230;..hange-case ?

      [[:blank:]]+Z (or z is equal). The posix [[:blank:]], undocumented, finds 13 spaces + Tabulation (InDesign CS4). Only space, Non-Breaking Space and Tab with InDesign CS3 (both with PC, perhaps different with Mac)

Viewing 5 reply threads
  • The forum ‘General InDesign Topics (CLOSED)’ is closed to new topics and replies.
Forum Ads