There are two spots where you do a multiplication when an addition would suffice. (Z - 1) / (\5 - 1) * \5 is better expressed as (Z - 1) + (Z - 1) / (\5 - 1). Same for \30. Those cost like 20 bytes each.
@Grimy Wow, that is absolutely magnificent! Would you like to post it as an answer? I'd like to give you some bounty for this.
@Grimy I'm aware of the bug. But that's the same as ()\1 isn't it? A lookahead will always trigger a no-match due to NEO+, so the (x) inside that lookahead will never be evaluated in any circumstance in ECMA.
If you've found a circumstance in which (?=anything)? will evaluate anything in proper ECMA then I definitely need to know.
Alright, here’s a 388 that passes 1-1000: https://pastebin.com/raw/hitQV1cZ I *think* it’s robust but I haven’t fully figured out the math. To get the 387 I mentioned earlier, just delete the first `x`.