SA-MP Forums Archive
Detect letters in 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: Detect letters in a string (/showthread.php?tid=529936)



Detect letters in a string - FullCircle - 04.08.2014

How to Detect if a string have other digits than letters?
Example:
[/pawn]"TEST" return false;
"T3ST" return true;
"TE$T" return true;
"TE_T" return true;
"TE.T" return true;
"TE!T" return true;
//etc...[pawn]


AW: Detect letters in a string - NaS - 04.08.2014

pawn Код:
stock IsLettersOnly(string[])
{
    for(new i = 0; i < strlen(string); i ++) if(tolower(string[i]) < 97 || tolower(string[i]) > 122) return 0;
    return 1;
}

returns 1 if the string has only letters, 0 if not.


Respuesta: AW: Detect letters in a string - FullCircle - 04.08.2014

Quote:
Originally Posted by NaS
Посмотреть сообщение
pawn Код:
stock IsLettersOnly(string[])
{
    for(new i = 0; i < strlen(string); i ++) if(tolower(string[i]) < 97 || tolower(string[i]) > 122) return 0;
    return 1;
}

returns 1 if the string has only letters, 0 if not.
Work, thanks