/ :`i$"A"; // 65 / :`i$"Z"; // 90 / :`i$"0"; // 48 / :`i$"9"; // 57 / :`i$":"; // 58 / :`i$"$"; // 36 testAtZ: { i:`i$x; $[(i>64) & (i<91);1;0] }; test0t9: { i:`i$x; $[(i>47) & (i<58);1;0] }; testcol: { i:`i$x; $[i=58;1;0] }; testend: { i:`i$x; $[i=36;1;0] }; s0: ((testAtZ; 1);(test0t9; 2)); s1: ((test0t9; 2);(testcol; 3)); s2: ((testend; 7); (testcol;5)); s3: (,(testAtZ; 5)); s4: ((testAtZ; 5); (test0t9; 5)); s5: (,(testend; 6)); s7: (({`0:"SUCCESS"};6)); // 7 is done states:: (s0;s1;s2;s3;s4;s5;s7); i: 1; run: {[str] str,:"$"; // go over each char and run cur statoe // cur state; start of pattern; length of pattern <- args idx::0; o:(0;-1;-1) {[a;c] // TODO, add support for multiple active states s: a[0]; r:{ :$[x[0][y];x[1];0] }[;c]'states[s]; r: *($[(+/r)>0;r^0;0]); idx +: 1; :(r;$[(s=0)&(r>0);idx-1;a[1]];$[r=5;idx;a[2]]) }\str; :o };