C
C#3y ago
Down

❔ string modify

how can i transform string like this 1234 5678 9123 4567 to this 1234 **** **** 4567 in a lambda function
7 Replies
Down
DownOP3y ago
public string CardNumber { get; set; }
public string CardNumberHidden => CardNumber ...
public string CardNumber { get; set; }
public string CardNumberHidden => CardNumber ...
Pobiega
Pobiega3y ago
A few different ways. You could split on spaces, separate the first and the last element then replace the rest with *. or you could count total amount of chars and use range indexes to extract the parts you want to show
Down
DownOP3y ago
okay thanks
Pobiega
Pobiega3y ago
Let me know if you get stuck
Down
DownOP3y ago
aight
canton7
canton73y ago
Regex is another options, of course
Accord
Accord3y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?