progs/catastrophic.js
author Christian Urban <urbanc@in.tum.de>
Sun, 28 Jul 2019 14:24:46 +0100
changeset 624 8d0af38389bc
parent 614 be065677c8f1
child 701 681c36b2af27
permissions -rw-r--r--
updated to Scala 2.13




// A case of catastrophic backtracking in JavaScript/Node.js
//
// regex: (a*)*b
// strings: aa...
//
// call with:
//
//  $> node catastrophic.py 20
//
// call with timing as:
//
//  $> time node catastrophic.py 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)