Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: None  |  size: 0.28 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Javascript Regex to split a string into array of grouped/contiguous characters
  2. var matches = 'aaaabbbbczzxxxhhnnppp'.split(/((.)2*)/g);
  3.     for (var i = 1; i+3 <= matches.length; i += 3) {
  4.         alert(matches[i]);
  5.     }
  6.        
  7. var matches = 'aaaabbbbczzxxxhhnnppp'.match(/((.)2*)/g);