0

Advice on how to write

  • took the root "aero", but

  • with the exception of "aerosol", "aerob"?

    (aero) -- Finds the group of a character in a given order.

    [^aerosol]|[^aerob] - Excludes words containing combinations of letters "aerosol", "aerob"?

Yaroslav
  • 87
  • 2
  • 10

1 Answers1

1

I think you're looking for a negative lookahead, which is a way of making sure that certain characters aren't found after a match -- in your case, you want aero but not aero-sol or aero-b (dash just used for affect). Here would be an example:

enter image description here

David542
  • 104,438
  • 178
  • 489
  • 842
  • 1
    You don't need the non-capture group. `^aero(?!sol|b)\w*$` is sufficient (as I'm sure you know). IMO it would be clearer to write, "...but not aerosol or aerob...". – Cary Swoveland May 27 '23 at 08:12