I'm having trouble with GREP outside of basics. I am using GREP to apply text styles to a paragraph. The text has been provided to me this way:
The colors starts as <ital>black<ital> and gradually progresses to <ital>white<ital>.
I'm using this: (<ital>).+(<ital>), which works fine in most circumstances. It fails on the above example, because it also italicizes "and gradually progresses to", which I don't want.
Can anyone be so kind as to point me in a direction of an explanation of what I'm doing wrong here?
Thanks in advance
By default, GREP is Greedy and tries to match as much as text as possible. In your example
dave-o-design wrote:
The colors starts as <ital>black<ital> and gradually progresses to <ital>white<ital>.
your match <ital>.+<ital> will match everything from the first to the last code. To switch to non-greedy mode, making it match the shortest possible match, change .+ to .+? like this:
<ital>.+?<ital>
You're exactly correct. The text has been supplied to me in a format where things that need to be italicized have been bookended with <ital>. I need to italicize both the words "black" and "white" in the following sentence:
The colors starts as <ital>black<ital> and gradually progresses to <ital>white<ital>.
The basic GREP expression I'm using works for most instances, but when it runs on the above example, it italicizes everything between the first <ital> before "black" and the last one after "white". I need it to italicize ONLY the words "black" and "white", without including the phrase "and gradually progresses to" that sits between them.
North America
Europe, Middle East and Africa
Asia Pacific