how to check if there's a CHAR inside 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: how to check if there's a CHAR inside a string? (
/showthread.php?tid=409667)
how to check if there's a CHAR inside a string? -
PaulDinam - 22.01.2013
I want to check for example if '@' exist in a string.
Re: how to check if there's a CHAR inside a string? -
[XST]O_x - 22.01.2013
pawn Код:
for(new i = 0; i < strlen(string); i++)
{
if(string[i] == '@')
{
//The string contains @.
}
else //The string doesn't contain @.
}
Re: how to check if there's a CHAR inside a string? -
Babul - 22.01.2013
Код:
if(strfind(string,"@",true,0)>-1)
...stringfind returns the position of the (first) found char - if the desired char/string is not found, it will return -1.
Re: how to check if there's a CHAR inside a string? -
PaulDinam - 22.01.2013
I made this:
it's good?
Код:
if(strfind(email, "@gmail.com", true) != -1 || strfind(email, "@hotmail.com", true) != -1 || strfind(email, "@walla.com", true) != -1 || strfind(email, "@walla.co.il", true) != 1 || strfind(email, "@yahoo.com", true) != 1 || strfind(email, "@aol.com", true) != 1)
{
Re: how to check if there's a CHAR inside a string? -
EpicNinja - 22.01.2013
It's alright. you should've tested it?
Re: how to check if there's a CHAR inside a string? -
PaulDinam - 22.01.2013
it works when i only write the whole part like
@gmail.com
when im doing
dsfdsf@email.com
it works