Not real clear on exactly what you want to have happen.
Just guessing, but if you put this in the Find What field …
… 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.
It wasn't clear? I'll try again.
Sample text (including the tags):
I'm trying to grep all the text between the first tag in angle brackets
and the final tag in angle brackets, even if this spans more than one
paragraph. So in the above example, I want to get all the text from the
first "this" through to the last "quote." In this case that is 2 paragraphs.
How would I grep such a thing?
No, that's not what I meant. I must be explaining this very badly. I
simply want to find all text between even when it spans
Is this an email problem? I'm sending this post via email, and it could
be that the tags are coming out in the Forum as formatting instead of
I think the email is screwing things up here, so I'm going to ask this a
I want to search for all the text between the word Elephant and the word
Tiger in the following text
Elephant is an animal with a trunk
An animal with stripes is a tiger
What grep expression can I use that will find all the text between
Elephant and Tiger?
There isn't any sample text coming through at all.
Try this in the Find Field:
So that's three sub-expressions.
- The first one will find the opening tag;
- 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);
- 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.
Thanks very much Bill.
This email interface could do with some work. If I had Internet access
right now I would use it and stop making people double-guess.... But I
don't right now.
Anyway, I figured out that I could use a | (or) sign, and that gives as
many paragraphs as needed. Plus a non-greedy ? so that it stops as soon
as it reaches the first end-tag. Pretty much the same as you solution,
but a bit more efficient perhaps.
Thanks again for your time and help,
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.
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...
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.