Copy link to clipboard
Copied
I am working on a variable data (XMPie) job, and the data has <i>...</i> tags in it which I am using to italicize text in the middle of a paragraph. I am using the grep expression: (?<=<i>).*(?=</i>) to locate the tags and italicize the content between them. It works great, except when a forced line break happens between the tags. When that happens this grep expression stops working. Any thoughts on how I can fix this?
<i>\K\X*?(?=</i>)
(^/) The Jedi
Copy link to clipboard
Copied
Have you tried:
(?<=<i>).*\n?(?=</i>)
Copy link to clipboard
Copied
Yes. Just did. Does not work. Here is the story text...
<i>“Stay close to my light. You don’t want to get lost on the rocks.”
—Fejenar, Silundi lullmage</i>
The forced line break happens after the close quote, and before the em-dash. Everything works great if the forced line break isn't in there. Add it, and the grep expression isn't found.
Copy link to clipboard
Copied
Hmmm. Did you try:
(?<=<i>).*\R?(?=</i>)
Copy link to clipboard
Copied
Yes, actually, I tried that immediately following your suggestion: (?<=<i>).*\n?(?=</i>)
Also does not work. 😞
Copy link to clipboard
Copied
How about
(?<=<i>).*?\R*.*?(?=</i>)
-Manan
Copy link to clipboard
Copied
YES!!! That worked!
Thank you!
Copy link to clipboard
Copied
Use single line mode:
(?s)(?<=<i>).*?(?=</i>)
Or this:
(?<=<i>)(.*?\n?)*(?=</i>)
Copy link to clipboard
Copied
<i>\K\X*?(?=</i>)
(^/) The Jedi
Copy link to clipboard
Copied
Shorter is better! 🙂
Copy link to clipboard
Copied
… More precisely:
"Pluralitas non est ponenda sine necessitate." [Ockham, 1319]
😉
Copy link to clipboard
Copied
What does \X refer to/define as? Is it for everything?
Copy link to clipboard
Copied