View Single Post
  #6  
Old 03-26-2008, 08:16 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
PHP Code:
function findpatterns(str) {
  
temp.outc = {};
  
temp.out = {};
  
temp.sub = "";
  
temp.p = 0;
  
temp.i = 0;
  
temp.e = 0;

  for (
i = 2; i < str.length(); i ++) {
    for (
e = 0; e < str.length(); e ++) {
      if (
e + i > str.length() - 1) {
        continue;
      }
      
sub = str.substring(e, i);
      
p = str.positions(sub);
      if (
p.size() > 1) {
        if (
outc.index(sub) < 0) {
          
outc.add(sub);
          
out.add({sub, p.size()});
        }
      }
    }
  }
  return 
out;
} 
__________________

Last edited by Inverness; 03-26-2008 at 01:28 PM..
Reply With Quote