Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
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... :-)
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!
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.