How does the =>
operator work and how does m
come into existence in the following code ?:
using System;
using System.IO;
using System.Text.RegularExpressions;
public class Test
{
public static void Main()
{
var line = "Keeping the line intact, replace me, but not you, keep this too.\n\nRetaining me, replace one, but not two, ignore three.";
var res = Regex.Replace(line, @"replace (?<target>.*), but not (?<source>.*),", m => "replace " + m.Groups["source"].Value.Replace("o", "1") + ", but not " + m.Groups["source"].Value + ",");
Console.WriteLine(res);
}
}
See the online compilation & output here.
EDIT:
This question is a duplicate but it should remain visible to searches because nowhere on StackOveflow is possible to find this association by searching for: =>
or for its English expansion: equals greater
. The first duplicate questions refers to it as arrow
which caused my searches to return - NO HITS.
An "arrow" is e.g.: →
(U+02192) , not the two characters =>
EDIT EDIT:
Never mind, the first duplicate question's title has been edited and now the search finds it with the search terms =>
or its English expansion "equal greater".