Skip to content

Instantly share code, notes, and snippets.

@ianstarz
Created March 15, 2016 17:24
Show Gist options
  • Save ianstarz/72b2190f300e83282d2b to your computer and use it in GitHub Desktop.
Save ianstarz/72b2190f300e83282d2b to your computer and use it in GitHub Desktop.
Find the longest common prefix in a list of strings using only a regex
['aaawhu', 'aaaajkssh', 'aaahwv', 'aaa'].join().match(/^(\w*)\w*(?:,\1\w*)*$/).pop();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment