0

Hello all.
I have a string that will contain the username, for the security reasons i want it to be checked it if its diferent from the specific charset.
I think it could be done by looping the check 1 character from the username at a time till the end of it, but is there any faster way to do it?
For example:
$charset="abcd1234";
$string1="312";
$string2="5abc";
It should return that $string2 is not contained in the charset.
Thanks in advance.

3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by EvolutionFallen
0

Hello all.
I have a string that will contain the username, for the security reasons i want it to be checked it if its diferent from the specific charset.
I think it could be done by looping the check 1 character from the username at a time till the end of it, but is there any faster way to do it?
For example:
$charset="abcd1234";
$string1="312";
$string2="5abc";
It should return that $string2 is not contained in the charset.
Thanks in advance.

http://php.net/preg_match That is all

0

The problem is that the charset will not have all possible usernames.
Larger example would be :
$charset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$username="abb";
$username="0000b";
$username2="_abb";
Two first are valid and the 3rd one isnt.
Err,i think im really dumb, creating a charset and trying to compare latter a latter , when i have [A-Za-z0-9]{4,10} lol =)
Ty for help.

Edited by jen140: n/a

0

The problem is that the charset will not have all possible usernames.
Larger example would be :
$charset="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$username="abb";
$username="0000b";
$username2="_abb";
Two first are valid and the 3rd one isnt.
Err,i think im really dumb, creating a charset and trying to compare latter a latter , when i have [A-Za-z0-9]{4,10} lol =)
Ty for help.

You're welcome =)

Edited by EvolutionFallen: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.