Example :9910109090
Output : ******9090
Example :9910109090
Output : ******9090
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Oct 27, 2021, 1:34 AM EDT
Shweta LodhaRank #31 · 39.8K reputationPosted Oct 27, 2021, 6:52 PM EDT
Do you want to mask the value when user is providing or you want to mask a value which you are already holding in a variable?
If you want to perform on this on a value already hold by a variable then this would work:
var temp = Regex.Replace(str, "[0-9]", "*" ); str = temp + str.Substring(str.Length - 4, str.Length - (str.Length - 4));Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Oct 27, 2021, 8:31 AM EDT