updated
authorChristian Urban <urbanc@in.tum.de>
Thu, 29 Nov 2018 02:37:01 +0000
changeset 614 be065677c8f1
parent 613 bfd511b7ecbf
child 615 e722f4ba54de
updated
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)