how to check if there's a CHAR inside a string?
#1

I want to check for example if '@' exist in a string.
Reply
#2

pawn Код:
for(new i = 0; i < strlen(string); i++)
{
    if(string[i] == '@')
    {
        //The string contains @.
    }
    else //The string doesn't contain @.
}
Reply
#3

Код:
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.
Reply
#4

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)
	{
Reply
#5

It's alright. you should've tested it?
Reply
#6

it works when i only write the whole part like
@gmail.com

when im doing dsfdsf@email.com
it works
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)