I was learning regex with JavaScript and this code seems to be very slow.
/(a*a*)*b/.test("aaaaaaaaaaaaa")
To me it seems really straight forward, can someone explain to me why is this happening ?
I was learning regex with JavaScript and this code seems to be very slow.
/(a*a*)*b/.test("aaaaaaaaaaaaa")
To me it seems really straight forward, can someone explain to me why is this happening ?
Regexes are in general slow, in terms of the effort they need to find matches. Some, in the server side can even be exploited for DOS attacks.
Basically each regex is the representation of its own logic, a syntax that actually represents a matching algorithm. In your case, it needs to figure out the match for the wildcard expansions. This is a simple regex, but still needs to be interpreted and check against the input.