Longest Delimited Substring
A delimited string is a string that starts with a character, ends with the same character, and doesn't contain the character anywhere else (besides the beginning and end). Here are some examples:
"abbbbbbba"is delimited because it starts and ends with
"ajjjjaffa"is not delimited because, though it starts and ends with
\a, it also contains
"bkfifoifu"is not delimited because it doesn't end with the same character it starts with.
Your task is to write a function that returns the longest delimited substring of a given string.
(delimited "ffdsfuiofl") ;=> "fuiof" (delimited "abbcdefg") ;=> "bb" (delimited "opoiifdopf") ;=> "poiifdop"
In the case of ties, return the substring that appears first.
Please submit your solutions as comments on this gist.
To subscribe: https://purelyfunctional.tv/newsletter/