Created
March 15, 2016 17:24
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
['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