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

Conditional text in a positive lookbehind grep sequence

Contributor ,
Aug 09, 2024 Aug 09, 2024

I'm trying to create a grep string that will subscript a symbol but only after specific words and not all instances of the symbol. 

In the example below I want the % subscripted when used after Melon and Apple but no other use of % should be subscripted.

I cant figure out what I'm doing wrong?

(?<=[Grape|Orange|Apple|Bananna|Avocado|Melon|Pineapple])%

 Screenshot 2024-08-09 at 4.44.00 PM.png

TOPICS
How to , Scripting , Type
474
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 10, 2024 Aug 10, 2024

Robert,

 

Bad answer! …

 

Right Grep syntax:

 

(Grape|Orange|Apple|Bananna|Avocado|Melon|Pineapple)\K%

 

(?<= …) just doesn't work with such a variable list!

 

(^/)  The Jedi

Translate
LEGEND ,
Aug 09, 2024 Aug 09, 2024

[] is for any Character from the list - you should rather use () instead. 

 

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 10, 2024 Aug 10, 2024

Robert,

 

Bad answer! …

 

Right Grep syntax:

 

(Grape|Orange|Apple|Bananna|Avocado|Melon|Pineapple)\K%

 

(?<= …) just doesn't work with such a variable list!

 

(^/)  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
Contributor ,
Aug 11, 2024 Aug 11, 2024
LATEST

Oooh I have not used \K ... 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