none
VS2012 Replace All does not do the same thing as Find Next, Replace. RRS feed

  • Question

  • I'm trying to use Visual Studio's Replace All feature with a regular expression.

    Here is my pattern: "^(?<before>[^\r\n]*\w[^/\r\n]*)///(?=[^<])" with "

    What is should find:

      int 0; /// comment

    And replace it with:

      int 0; ///< comment

    "Find Next" and "Find All" buttons from the "Find in Files" dialog finds occurrences of my pattern.

    "Find Next" button from the "Replace in Files" dialog finds occurrences of my pattern.

    "Replace" button from the "Replace in Files" dialog transforms the text like I expect.

    "Replace All" button from the "Replace in Files" doesn't find any occurrences of my pattern.

    Why doesn't "Replace All" find the same regex matches that "Find Next" and "Find All" do?

    Update:

    Replace All “(?<before>^[^\r\n]*\w[^/\r\n]*)///” with “${before}///<” works.
    Replace All “(?<before>^[^\r\n]*\w[^/\r\n]*)///[^<]” with “${before}///<” works.

    The problem is the look ahead block "(?=[^<])".

    I've used look ahead blocks in other regex with Replace All , so I'm not sure why it doesn't work in this case.



    Friday, September 7, 2012 7:40 PM

Answers

All replies