0

I am creating some regex that should replace > characters in an expression with >. So in expression="x > 10" it should become expression="x > 10". But if my expression doesn't contain a > then the regex is greedy and grabs > outside of quotation marks. For example the following gets incorrectly converted: expression="9a / 3b - 10c" > foo="67 + 34" to expression="9a / 3b - 10c" > foo="67 + 34"

Do you know how I can make my regex not search past the second " (or ')?

My regex is: (expression=["|'].*?>)(.*?["|'])

Here is an example of the error occurring: https://regex101.com/r/aQuPmd/1/

sazr
  • 21,294
  • 58
  • 170
  • 304

0 Answers0