Ad
  • Custom User Avatar

    Interestingly, there are two possible ways to handle embedded content: remove all non-braced content first, or include something like [^\)]* between each set of braces. Neither option is as trivial to implement if we include string content with possible braces.

    Of course, it is terribly inefficient. Even more so, because I lazily chose to not make the RegExp global, because it wasn't matching the test at first. So it has to match and replace each pair of braces repeatedly... :-)

  • Custom User Avatar

    Actually, for this particular requirement this would be efficient in certain cases where multiple matches are created and removed on each swipe. I have to say, this is a very elegant solution.

    However, I would like to also to point out that this solution could not be applied to a more common scenario where braces have content. Your code would not be as "cute" in that case. But this was not the requirement of this Kata, so, well done!

  • Custom User Avatar

    Um -- anyone who writes "less than" to mean "less than or equal to" is doing it wrong. Just saying.... I don't know if their semantic confusion merits making this change.