Skip to main content
Inspiring
June 18, 2020
Answered

How can I use lookahead/lookbehind one segment at a time!

  • June 18, 2020
  • 1 reply
  • 720 views

Here is an example of the raw text:

 

At the time her design became the mascot, Murphy was featured in the [i]ReminderNews[/i], which was later acquired by The [i]Hartford Courant[/i] in 2014, and later renamed [i]Courant Community[/i].

 

Latest lame attempt to "catch" the middle characters, then use Found Text to change them to ital:

(?<=(\[i\])).+(?=(\[\/i\]))

My problem is that it keeps selecting all the text end to end.  I can't seem to have the "Match" commands stop and format stop and format.  Now, my brain hurts and hoping someone can straighten out my game.

 

 

This topic has been closed for replies.
Correct answer jctremblay

My first GREP grabs the words and applies the italics.

Another GREP that follows removes the markup left behind.


You can achieve it in one query...

Find: \[i\](.+?)\[\/i\]
Change: $1

1 reply

MadMac55Author
Inspiring
June 18, 2020

Tada!   Knew it was in ther somewhere (shortest match!!)

 

(?<=(\[i\]))(.*?)(?=(\[\/i\]))

jctremblay
Community Expert
Community Expert
June 18, 2020

No need to put them into a sub-expression or use the * (unless you want to catch empty text like [i][/i]).

(?<=\[i\]).+?(?=\[\/i\])

 

MadMac55Author
Inspiring
June 18, 2020

My first GREP grabs the words and applies the italics.

Another GREP that follows removes the markup left behind.