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

GREP expression to italicize not working with forced line break

New Here ,
Aug 31, 2020 Aug 31, 2020

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
1.1K
Translate
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

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

Have you tried:

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

Mike Witherell
Translate
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

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.

Translate
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

Hmmm. Did you try:

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

Mike Witherell
Translate
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

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

 

Also does not work. 😞

Translate
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

How about 

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

-Manan

Translate
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

YES!!! That worked!

Thank you!

Translate
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

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

Or this:

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




Translate
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

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

 

(^/)  The Jedi

Translate
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

Shorter is better! 🙂 

Translate
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
LATEST

… More precisely:

 

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

 

😉

Translate
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

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

Mike Witherell
Translate
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
Translate
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