Censoring parts of a string - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Censoring parts of a string (
/showthread.php?tid=664356)
Censoring parts of a string -
C0oL3r - 26.02.2019
Hello, how can i censore parts of a string like from
testemail@yahoo.com to tes******@ya***.com
Re: Censoring parts of a string -
andrejc999 - 26.02.2019
You can make a loop to go through every char. and replace the ones you want.
Re: Censoring parts of a string -
C0oL3r - 27.02.2019
And how i would do that, i tried looping with an for through all characters but i don't know how to replace what i want
Re: Censoring parts of a string -
Kaliber - 27.02.2019
You can do it like this:
PHP код:
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