Home > Uncategorized > Regex in Find-and-replace in Visual Studio for left-angle brackets

Regex in Find-and-replace in Visual Studio for left-angle brackets

My problem is simple. Sandcastle requires encoded html to parse correctly. Having generics in the documentation causes it to break. I need to replace the '<' with &lt;. I just now need to do this by the solution in Visual Studio. Of course, microsoft requires me to know another regex set of expresssions: http://msdn.microsoft.com/en-us/library/2k3te2cs(VS.80).aspx

Here’s the simple regex:

  • Find: ///{.*}{[^:b\>\.]}(\<)
  • Replace: ///&lt;

The regex looks for a left angle bracket on the end of a word (ie no space, no period). This means that it also leaves html in place.

Find and Replace in Visual Studio 2008

Note: I wouldn’t do a global replace but use it to step through each.

Before:

    /// <summary>
    /// Used for testing the redirection of action on successful and failing calls to an action.   
    /// <example>
    ///    [TestClass]
    ///    public class UserControllerRedirectsTest
    ///    {
    ///        [TestMethod]
    ///        public void SuccessfulCreateRedirectsToIndex()
    ///        {
    ///            Controller<UserController>
    ///                .ShouldRedirectTo(ResfulAction.Index)
    ///                .IfCallSucceeds()
    ///                .WhenCalling(x => x.Create(null));
    /// </example>
    /// </summary>
    /// <typeparam name="T"></typeparam>

After:

    /// <summary>
    /// Used for testing the redirection of action on successful and failing calls to an action.   
    /// <example>
    ///    [TestClass]
    ///    public class UserControllerRedirectsTest
    ///    {
    ///        [TestMethod]
    ///        public void SuccessfulCreateRedirectsToIndex()
    ///        {
    ///            Controller&lt;UserController>
    ///                .ShouldRedirectTo(ResfulAction.Index)
    ///                .IfCallSucceeds()
    ///                .WhenCalling(x => x.Create(null));
    /// </example>
    /// </summary>
    /// <typeparam name="T"></typeparam>
Categories: Uncategorized Tags: ,
  1. No comments yet.
  1. No trackbacks yet.