I asked What features would you like in the next version of Visual C#? and got an interesting response back from Duncan who asks for regular expressions to be treated as an operator as the are in JavaScript and Perl.  I see there being two ways of accomplishing this.  One is to specifically add regexp support to the C# language.  I don't really like this since it's focusing on just one small enhancement to the language and I would prefer a more general approach that would apply to more things than just the niche of string processing.

Currently in VS we have the concept of embedding different types of code together.  Specifically ASP.Net.  For example I can do the following in the .aspx page I am authoring:


<script runat="server">

    public void Foo()


        Response.Write("Whee I'm embedding C# inside html!");



When you're outside of the “script” tag you get all the benefits of the html editor, and when you're inside you're suddenly interacting with the C# editor with all the benefits that you're used to (intellisense, colorization, goto definition, etc.).  However, this is the limit of what you can do.  Just nesting C#/VB/J# inside html.  I would like to take that concept and extend it out to any level. 

There are already cases today that would benefit from that.  The first is that VS2005 will ship with a powerful XML editor, and C# doc comments are written in XML, so why not use that editor instead for editing your comment?  If you did that then you'd get the great immediate feedback that the XML editor provides (like telling you that you can't embed & in your comments, etc.).  Since we have a clear code marker with /// it should be possible to then host the XML editor there and have it take care of all that.  So you could then have XML Editor in C# editor in Web editor.  You could even apply that down to general purpose languages.  I would love it if when I typed:

Regex r = new Regex

We then realized you were entering the domain specific langauge of regexps and we could provide you intellisense help.  ErigGu wrote a cool tool called Regular Expression Workbench that would be cool to modify and embed as you were typeing the pattern.  That way you could test out the pattern as you were writing it and could see how the matching groups worked, etc.

Other applications would be if you were typing a new SQL query.  Or if you were doing something extremely bizarre if inside that sql query you started using xml and then were writing C# inside a CDATA block.  Can you think of other places where you'd like to see this?  Are there other tools that handle this well now?  Is it worth investigating into this, or would you just prefer that the language support regexps natively?