I couldn't seem to find a match for this question so my apologies in advance if it's a duplicate.
Given the template: <<FirstName>> << FirstName >>
I want to replace both strings between the '<<>>'
's using a single regex that should match both.
The following code doesn't seem to work the way I'm expecting:
[Test]
public void ShouldReplaceMultiple()
{
var pattern = "<<.*FirstName.*>>";
var template = "<<FirstName>> <<FirstName>>";
var replaceWith = "FOO";
var regex = new Regex(pattern);
Assert.AreEqual("FOO FOO", regex.Replace(template, replaceWith));
}
The output of the test is as follows:
Expected string length 7 but was 3. Strings differ at index 3.
Expected: "FOO FOO"
But was: "FOO"
--------------^
I don't understand why both strings won't be replaced?