author | Christian Urban <urbanc@in.tum.de> |
Tue, 08 Oct 2019 21:12:52 +0100 | |
changeset 649 | e83afb44f276 |
parent 614 | be065677c8f1 |
child 701 | 681c36b2af27 |
permissions | -rw-r--r-- |
614 | 1 |
|
2 |
||
3 |
||
4 |
// A case of catastrophic backtracking in JavaScript/Node.js |
|
5 |
// |
|
6 |
// regex: (a*)*b |
|
7 |
// strings: aa... |
|
8 |
// |
|
9 |
// call with: |
|
10 |
// |
|
11 |
// $> node catastrophic.py 20 |
|
12 |
// |
|
13 |
// call with timing as: |
|
14 |
// |
|
15 |
// $> time node catastrophic.py 25 |
|
16 |
||
17 |
||
18 |
const args = process.argv[2] |
|
19 |
||
20 |
var str = 'a'.repeat(args); |
|
21 |
||
22 |
console.log(str) |
|
23 |
||
24 |
var re = /^((a)*)*b$/; |
|
25 |
||
26 |
var res = re.test(str); |
|
27 |
||
28 |
console.log(res) |