Home > Blockchain >  Regular expression to find string which is not part of bigger subscript
Regular expression to find string which is not part of bigger subscript

Time:07-11

I have a very big file with text and want to find:

  1. all occurrences of string selectedRow which are not:
  2. part of selectedRowIds
  3. are proceeded by props.

I am interested in line numbers where all of these conditions are met.

Is is possible to achieve with RegExp?

So e.g. for test data:

this.state.selectedRow
this.props.selectedRow
selectedRowIds

it will match only first line.

CodePudding user response:

You can use look around to exclude matches with particular prefix/postfixes:

(?<!props\.)selectedRow(?!Ids)?
  • Related