Remove Nested Patterns with One Line of JavaScript
Steven Levithan has been flagrant by creating a simple way to remove nested patterns with a while loop and a replace: PLAIN TEXT JAVASCRIPT: var str = “abc<1<2<>3>4>def”; while (str != (str = str.replace(/<[^<>]*>/g, “”))); // str -> "abcdef" Notice that the regex in this one-liner doesn’t try to deal with nested patterns at all. The while loop’s condition replaces instances [...]