I am looking into extending Regexp.fromString to handle ^ and $, and I have a couple of questions. The "upper" function, used to implement range, appears broken to me. Here is the definition. fun upper (r, n: int) = if n = 0 then null else or [r, upper (r, n - 1)] I would assume that you want upper (r, 3) to return null | r | rr | rrr Also, is there any reason why you didn't just translate ^ as AnchorStart?