I'm trying to create a JS regex that matches !next
either at the beginning or end of the line.
Currently I'm using /(^!next|!next$)/i
which works. However that's obviously kind of ugly to read and not DRY, so I'm looking to improve.
The closest I've come is this:
/(?=!next)[^$]/i
But that actually just matches everything (and it occurs to me now that I misremembered the way that ^
works inside character classes, so this solution is garbage anyway).
I've searched the web and SO, and I'm totally stumped.