Checking characters in string
#8

After checking that the name is valid (Name_Lastname, it uses only 1 underscore and not at the start or end etc), use:
pawn Код:
if (CheckChars(inputtext))
{
    // your code
}
pawn Код:
stock CheckChars(const source[], length = sizeof (source))
{
    if (!(--length)) return 0;
   
    new
        pos = strfind(source, "_");
   
    for (new i; i != length; ++i)
    {
        if (!i || i == pos + 1)
        {
            switch (source[i])
            {
                case 'A' .. 'Z': continue;
                default: return 0;
            }
        }
        else if (i && i != pos && i != pos + 1)
        {
            switch (source[i])
            {
                case 'a' .. 'z': continue;
                default: return 0;
            }
        }
    }
    return 1;
}
Reply


Messages In This Thread
Checking characters in string - by Riwerry - 29.01.2014, 13:45
Re: Checking characters in string - by Wizz123 - 29.01.2014, 13:53
Re: Checking characters in string - by Riwerry - 29.01.2014, 14:09
Re: Checking characters in string - by Wizz123 - 29.01.2014, 14:24
Re: Checking characters in string - by Riwerry - 29.01.2014, 14:32
Re: Checking characters in string - by Wizz123 - 29.01.2014, 14:34
Re: Checking characters in string - by Riwerry - 29.01.2014, 14:39
Re: Checking characters in string - by Konstantinos - 29.01.2014, 14:52
Re: Checking characters in string - by Riwerry - 29.01.2014, 14:54
Re: Checking characters in string - by Konstantinos - 29.01.2014, 15:10

Forum Jump:


Users browsing this thread: 1 Guest(s)