Why does this regex alternate between true and false? It seems like it should match the "approv" at the beginning and always return true
. No matter what, it doesn't seem like it should alternate.
const filter = /(approv)/gi // Also happens with /.*(approv).*/gi
console.log(
filter.test("approv"),
filter.test("approve"),
filter.test("approvd"),
filter.test("approved!"),
filter.test("approved!!"),
filter.test("approved!!!")
)