Okay, well this thread has been dead for sufficiently long time. Here is what I came up with; it takes quadratic time.

PHP Code:

```
``````
function onCreated() {
```

temp.p = getpatterns("THISISATESTSTRING");

for (temp.s: temp.p) {

if (this.(@"h_"@temp.s) >= 2)

echo(temp.s @ ": "@ this.(@"h_"@temp.s));

this.(@"h_"@temp.s) = 0; /* clean-up */

}

}

function getpatterns(s) {

temp.l = s.length();

for (temp.i=0; temp.i<temp.l-1; temp.i++) {

temp.c = s.charat(temp.i);

for (temp.j=temp.i+1;temp.j<temp.l;temp.j++) {

temp.c @= s.charat(temp.j);

this.(@"h_"@temp.c) ++;

temp.pat.add(temp.c);

}

}

return temp.pat;

}

Perhaps there are still improvements to be made.