Skip navigation
Currently Being Moderated

GREP Help

Jul 25, 2012 3:37 PM

Hello,

 

For once, my editor behaved herself and enclosed all block-quotes in

tags.  tags?

 

Thanks,

Ariel

 

 
Replies
  • Currently Being Moderated
    Jul 25, 2012 3:50 PM   in reply to [Ariel]

    What's the question, and what sort of tags?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 3:54 PM   in reply to [Ariel]

    Not real clear on exactly what you want to have happen.

     

    Just guessing, but if you put this in the Find What field …

     

    (tag)(.)

     

    … and replace where it says tag with the actual tag (if they used square brackets [Block] you'll need to escape from them with backslashes … \[Block\])

     

    Put $2 in the Change To field …

     

    … and then your Block Quote style in the Change Format field.

     

    It'll look for your Tag and the next character following it and then replace them both with the following character only and bring in the style with it.

     

    Or maybe you had a different question.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 4:13 PM   in reply to [Ariel]

    Hi Ariel,

     

    There isn't any sample text coming through at all.

     

    Try this in the Find Field:

     

    (<TAG>)(.+\r*.*\r*.*\r*.*)(<\\TAG>)

     

    So that's three sub-expressions.

     

    1. The first one will find the opening tag;
    2. the second one will find any character one or more times, followed by a return zero or more times, followed by any character zero or more times (and again two more times — that's 4 paragraphs worth, add more \r*.* sections as needed);
    3. the third one will find the closing tag.

     

    And $2 in the change field will replace all of it with just the content of the second string. Change format to the style you want.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 4:25 PM   in reply to [Ariel]

    (?s)(<tag>)(.+?)(<tag>)

     

    Replace with $2

     

    This turns on Single Line Mode so it ignores the ends of paragraphs, but also looks for the shortest match so it will capture the the paragraphs, or groups of paragraphs, separately. Otherwise it would find everything between the first and last tag as one match.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 4:30 PM   in reply to Peter Spier

    Much tidier but you need to use a close tag in the last sub-expression.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 4:46 PM   in reply to bill_t12

    bill_t12 wrote:

     

    Much tidier but you need to use a close tag in the last sub-expression.

    Don't know what you're seeing that's missing. Works fine just as I pasted it and it appears on the web page here.

     

    Or are you thinking I meant html style tags: <tag> and </tag>? <tag> is just a placeholder for whatever the editor used...

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 4:52 PM   in reply to Peter Spier

    I was thinking that the editor used a different tag to close the quote.

     

    The way I was reading things it seemed like the search would go from the first open tag to the next open tag.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 4:54 PM   in reply to bill_t12

    Yeah, I can see how it was confusing. I made the assumption, perhaps false, that Ariel understood he should substitute the correct tags.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 26, 2012 1:55 AM   in reply to [Ariel]

    Arïel wrote:

     

    I played around with multiline mode (?m). That seemed more intuitive to

    me but it didn't work. In the end I found a slightly different solution

    to yours. I can't say I really understand what single line and multi

    line modes do...

     

    Single line mode (?s) changes the behavior of the . (period) operator. By default it's disabled and does not match a hard return, so the expression

     

    .+

     

    will always stop matching right before the next hard return. Enabling single line mode will essentially make your text one full long line, as far as the . wildcard is concerned.

     

    You typically need this modifier if you want to grab a match over multiple paragraphs.

     

    Multiple line mode (?m) changes the behavior of the ^ and $ anchor points. By default it is enabled and matches the start and end of a paragraph (right after and before a hard return). Disabling will make ^ and $ only match the very start and the very end of an entire story (the largest single unit of consecutive text in InDesign).

     

    This sounds weird because it seems like the default mode is "normal", and therefore there would be no use to be able to disable this flag. However, originally GREP was designed for simple text line processing, inside of which you'd never would find a hard return. When support for hard returns as 'end of paragraph' got added, GREP needed a modifier to discern between start-of-text and start-of-new-paragraph.

     

    InDesign supports \A and \Z for start and end of story, so you don't need to change this flag, but you get it for free anyway because it's built in into the standard GREP library that Adobe used.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)