# HG changeset patch # User Christian Urban # Date 1543459021 0 # Node ID be065677c8f1360c0887e847d91a002b3a7c62a5 # Parent bfd511b7ecbf7360cc2cbca6f6cc7d5e6599ffe9 updated diff -r bfd511b7ecbf -r be065677c8f1 progs/catastrophic.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/progs/catastrophic.js Thu Nov 29 02:37:01 2018 +0000 @@ -0,0 +1,28 @@ + + + +// 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)