progs/catastrophic.js
author Christian Urban <urbanc@in.tum.de>
Sun, 22 Mar 2020 14:21:33 +0000
changeset 715 3cba5753bd77
parent 701 81377a3eb717
permissions -rw-r--r--
started dotty files




// A case of catastrophic backtracking in JavaScript/Node.js
//
// regex: (a*)*b
// strings: aa...
//
// call with:
//
//  $> node catastrophic.js 20
//
// call with timing as:
//
//  $> time node catastrophic.js 25


const args = process.argv[2]

var str = 'a'.repeat(args);

console.log(str)

var re = /^((a)*)*b$/;

var res = re.test(str);

console.log(res)