Regex AND operator

It is impossible for both (?=foo) and (?=baz) to match at the same time. It would require the next character to be both f and b simultaneously which is impossible. Perhaps you want this instead: (?=.*foo)(?=.*baz) This says that foo must appear anywhere and baz must appear anywhere, not necessarily in that order and possibly … Read more

What is “x && foo()”?

Both AND and OR operators can shortcut. So && only tries the second expression if the first is true (truth-like, more specifically). The fact that the second operation does stuff (whatever the contents of foo() does) doesn’t matter because it’s not executed unless that first expression evaluates to something truthy. If it is truthy, it … Read more