26.02.2019, 18:34
Hello, how can i censore parts of a string like from testemail@yahoo.com to tes******@ya***.com
stock CensorMail(const mail[])
{
new c = strfind(mail,"@"), p = strfind(mail,".",false,c+1), censored[64] = "Fake Mail!";
if(c == -1 || p == -1 || c < 3) return censored;
format(censored,64,mail);
for(new i=(c==3)?1:3; i<c; i++) censored[i] = '*';
for(new i=(p-c == 4)?c+2:c+3; i<p; i++) censored[i] = '*';
return censored;
}
//Example:
print(CensorMail("testemail@yahoo.com")); //Output: tes******@ya***.com
print(CensorMail("aaa@web.de")); //Output: a**@w**.de