• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

GREP expression to italicize not working with forced line break

New Here ,
Aug 31, 2020 Aug 31, 2020

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?

TOPICS
How to , Scripting

Views

616

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Aug 31, 2020 Aug 31, 2020

<i>\K\X*?(?=</i>)

 

(^/)  The Jedi

Votes

Translate

Translate
Community Expert ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Have you tried:

(?<=<i>).*\n?(?=</i>)

Mike Witherell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2020 Aug 31, 2020

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Hmmm. Did you try:

(?<=<i>).*\R?(?=</i>)

Mike Witherell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Yes, actually, I tried that immediately following your suggestion:  (?<=<i>).*\n?(?=</i>)

 

Also does not work. 😞

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

How about 

(?<=<i>).*?\R*.*?(?=</i>)

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

YES!!! That worked!

Thank you!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Use single line mode:
(?s)(?<=<i>).*?(?=</i>)

Or this:

(?<=<i>)(.*?\n?)*(?=</i>)




Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

<i>\K\X*?(?=</i>)

 

(^/)  The Jedi

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Shorter is better! 🙂 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Sep 01, 2020 Sep 01, 2020

Copy link to clipboard

Copied

LATEST

… More precisely:

 

"Pluralitas non est ponenda sine necessitate." [Ockham, 1319]

 

😉

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

What does \X refer to/define as? Is it for everything?

Mike Witherell

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines