Skip to main content
Inspiring
June 30, 2022
Answered

Find/Replace grep help

  • June 30, 2022
  • 2 replies
  • 389 views

I'm trying to find  something that matches a lookbehind of spaces or opening brackets but can't make it work. I want to be able to find a b c when preceeded by a space or opening bracket, but not capturing the space or bracket.

 

I want it to be the following but it seems classes don't work in positive lookbehind:

(?<=[ \(])[acb]

Looks simple enough but much googling is yielding nothing, I'm probably seartching for the wrong terms.

This topic has been closed for replies.
Correct answer Barb Binder

Hi @MrZZY 

 

Try:

 

(?<=\s|\[)abc

 

~Barb

 

2 replies

Barb Binder
Community Expert
Community Expert
June 30, 2022

Hi @MrZZY:

 

The pipe character means "or" so for example, look for a leading space before "abc" or look for the open bracket/parenthesis before "abc". 

 

And in the US, these are parentheses ( ) and these are brackets [ ], so we both learned something. 😊

 

~Barb

~Barb at Rocky Mountain Training
Barb Binder
Community Expert
Barb BinderCommunity ExpertCorrect answer
Community Expert
June 30, 2022

Hi @MrZZY 

 

Try:

 

(?<=\s|\[)abc

 

~Barb

 

~Barb at Rocky Mountain Training
MrZZYAuthor
Inspiring
June 30, 2022

Thanks so much! I meant opening parentheses (I don't know if it's the same where you are but in the UK brackets is often used to mean parenthese) but your answer contained the solution in terms of using the pipe character.