PHP Code:
function findpatterns(string) {
temp.time = timevar2;
temp.out = 0;
temp.check = 0;
for (temp.i = 2; i < string.length()/2; i ++) {
for (temp.j = 0; j < string.length()/2; j ++) {
if (i+j+2 > string.length()-2) continue;
temp.letters = temp.string.substring(j, i);
if (check.index(letters) > -1) continue;
if (letters.length() < 2) continue;
temp.pos = string.positions(letters);
if (pos.size() < 2) continue;
check.add(letters);
out.add({letters, pos.size()});
}
}
echo("Delta Time: "@ timevar2-time);
return out;
}
Example1:
PHP Code:
function onCreated() {
echo(findpatterns("TAPEREDATAPER"));
}
/*
output:
Weapon/GUI-script ChompyT added/updated by Chompy
Delta Time: 0.000427007
"TA,2","AP,2","PE,2","ER,2","TAP,2","APE,2","PER,2","TAPE,2","APER,2","TAPER,2"
*/
Example2:
PHP Code:
function onCreated() {
echo(findpatterns("AUGCCCGTAUACGTA"));
}
/*
output:
Weapon/GUI-script ChompyT added/updated by Chompy
Delta Time: 0.000540971
"AU,2","CC,2","CG,2","GT,2","TA,2","CGT,2","GTA,2","CGTA,2"
*/