var panmaskednumber = "543034******0243"; Console.WriteLine(panmaskednumber.Count(x => x == '*'));
var pattern = "\\*";
var replace = "123456789";
Regex reg = new Regex(pattern);
var newnumber = reg.Replace(panmaskednumber, replace,panmaskednumber.Count(x => x == '*'));
Console.WriteLine(newnumber);
I'm trying to Replace * in var panmaskednumber(coming from DB with symmetric key).
Not liking to use the Contains approach in which I'm specifying number of * 6 / 7 with multiple If-elseif. Since those can vary between 6,7-9.
With my above approach it replaces for each char of -> * with var replace. Any Linq approach if there is highly appreciated. Result something: 5430341234567890243
*'s count is greater that replace's length?