While useful to some I think advanced RE are like mixing in Perl or playing code golf with production code. They tend to make code harder to read. My preference in such cases is for multiple separated or longer REs (which can be at least split in the surrounding code) and each part named or heavily commented. Of course it's always worthwhile to consider non-RE solutions if the problem can be broken down enough. EDIT:…
Fair enough, but I really think the benefits of advanced regular expressions are underappreciated in non-production and even non-application contexts. Laypeople (and occasionally even developers) are impressed when you show them how to search through a document or file system using a really complicated pattern, where it would have taken several iterations of data manipulation to achieve the same result without using…
I'm not sure how you could fix that without introducing completely new characters or color-coding parts of the expression though.