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

Conditional text in a positive lookbehind grep sequence

Contributor ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

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

Views

175

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

Votes

Translate

Translate
Community Expert ,
Aug 09, 2024 Aug 09, 2024

Copy link to clipboard

Copied

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

 

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

Copy link to clipboard

Copied

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

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
Contributor ,
Aug 11, 2024 Aug 11, 2024

Copy link to clipboard

Copied

LATEST

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