-2

What is the appropriate RegEx ( javascript ) for selecting 'and' when it's not between double-quotes. like below:

def abc as "Hello and Welcome" and aaa as "Hi" and bbb as "and"

"and"s which are not included in double-quotes should be selected like below:

def abc as "Hello and Welcome" and aaa as "Hi" and bbb as "and"

Thank you

Shadow4Kill
  • 178
  • 1
  • 9

1 Answers1

1

Try this it works like a charm

and(?=[^"]*("[^"]*"[^"]*)*$)

It assumes if there are pairs of double quotes after and then this and is not in double quotes.

For demonstration have a look here

Rehan Haider
  • 893
  • 11
  • 26