Project match result directly to formated result string
RegEx.Matches(myText,searchPatten).Cast<Match>().Select(x => $"{x.Groups[1].Value} {x.Groups[2].Value}").ToArray();Here : Match a pattern and apply Replace on the resulting Match Collection, something like. RegEx.MatchAndReplace(myText,searchPattern,replacePattern);
This allows us to get the Index and the Length of each match along what it would be replaced with.
use Regex.Matches() and then on every Match do a Regex.Replace()
var regex = new Regex(searchPattern);
var matches = regex.Matches(myText)
.Cast<Match>()
.Select(x => new
{
Match = x,
ReplacedWith = regex.Replace(x.Value, replacePatten)
})
.ToArray();
```