Skip to content

Instantly share code, notes, and snippets.

@Peter-Hudson
Last active April 12, 2019 07:31
Show Gist options
  • Save Peter-Hudson/fce8655dc527a0ed013c80760cc70c82 to your computer and use it in GitHub Desktop.
Save Peter-Hudson/fce8655dc527a0ed013c80760cc70c82 to your computer and use it in GitHub Desktop.
There has to be a better version of this? Though I did this without searching the answer.
let testString = 'aaabbbbaa';
testString.match(/.+?(a+|b+|c+|d+|e+|f+|g+|h|i+|j+|k+|l+|m+|n+|o+|p+|q+|r+|s+|t+|u+|v+|w+|x+|y+|z+)/igm).map(c => c.length + c[1]).join('');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment