[Solved] How can I specify regular expression flags?

from what I can tell, the default flags ST uses are:

  • g: match more than once (don’t stop at first match)
  • m: ^ and $ match the beginning and end of lines, respectively
  • i: (depending on your Case Sensitive toggle state)

  • there is no way to disable g as far as I can tell, as it isn’t an inline option. If you don’t want to have multiple matches (I guess for performance reasons), maybe it is possible to make a condition in the regex to assert that it hasn’t matched previously?
  • boost doesn’t support X, u, U, A, J or D inline flags it seems, but it already operates in full unicode mode and the other flags don’t seem to be very useful from what I can see
  • if you want to disable m, you can use (?-m)
  • you can override case (in)sensitivity with (?i) or (?-i)
  • if you want . to match new lines, you can use (?s)
  • to enable/disable extended mode (ignoring whitespace in the expression and affecting comments) you can use (?x) and (?-x)

all these work perfectly in my testing

nope

2 Likes