[SOLVED] eregi expression
Moderator: General Moderators
[SOLVED] eregi expression
hi
how can i say that a sequence following the alphabet is rejected.
for example
abcdefghijklmnopqrstuvwxyz (rejected)
so if i put
abcdefgh (rejected)
fghijklmnopqrs (rejected)
pqrstuvwx (rejected)
bournemouth (accepted)
the input will be 8 to 12 characters
how can i say that a sequence following the alphabet is rejected.
for example
abcdefghijklmnopqrstuvwxyz (rejected)
so if i put
abcdefgh (rejected)
fghijklmnopqrs (rejected)
pqrstuvwx (rejected)
bournemouth (accepted)
the input will be 8 to 12 characters
Last edited by gurjit on Wed Jun 13, 2007 9:25 am, edited 1 time in total.
if anyone types in lets say
abcdefghijklmnopqrstuvwxy
from any part of the alphabet as
abcdefgh
abcdefghi
bcdefghijk
ijklmnopqr
mnopqrstuv
then it should be rejected.
however if they type
aabcdefgh
abbcdefgh
bccdefghijk
its is still accepted
The user will be able to type in any word between 8 and 12 chars
as long as the user does not enter a complete string of the alphabet as it is "abcdefghijklmnopqrstuvwxy".
hope this makes sense
what i'm trying to do is something like internet banking. the user creates a memorable word between 8 and 12 chars. At login the user is asked to recall 2 letters from there word. The 2 letters are random. (this part of the code is done. What I cant do is find a way to ensure users dont use a simple word like "abcdefgh" or "lmnopqrst".
abcdefghijklmnopqrstuvwxy
from any part of the alphabet as
abcdefgh
abcdefghi
bcdefghijk
ijklmnopqr
mnopqrstuv
then it should be rejected.
however if they type
aabcdefgh
abbcdefgh
bccdefghijk
its is still accepted
The user will be able to type in any word between 8 and 12 chars
as long as the user does not enter a complete string of the alphabet as it is "abcdefghijklmnopqrstuvwxy".
hope this makes sense
what i'm trying to do is something like internet banking. the user creates a memorable word between 8 and 12 chars. At login the user is asked to recall 2 letters from there word. The 2 letters are random. (this part of the code is done. What I cant do is find a way to ensure users dont use a simple word like "abcdefgh" or "lmnopqrst".
Last edited by gurjit on Tue Jun 12, 2007 9:04 am, edited 1 time in total.
what i'm trying to do is something like internet banking. the user creates a memorable word between 8 and 12 chars. At login the user is asked to recall 2 letters from there word. The 2 letters are random. (this part of the code is done. What I cant do is find a way to ensure users dont use a simple word like "abcdefgh" or "lmnopqrst".
how can i check for any weak combinations
how can i check for any weak combinations
First thing coming to my mind: Compare the sequence of character from left to right (for/while loop with (int)$char{$n}), the current character with the next and see if the next one is 1 number greater than the current. If it isn't, set $accepted to true and allow the input if $accepted has been set to true at some point.
Only works for A-Z and a-z though, no foreign letters.
Only works for A-Z and a-z though, no foreign letters.
Code: Select all
<?php
$haystack = 'abcdefghijklmnopqrstuvwxyz';
$tests = array(
'abcdefgh',
'abcdefghi',
'bcdefghijk',
'ijklmnopqr',
'mnopqrstuv',
'aabcdefgh',
'abbcdefgh',
'bccdefghijk'
);
foreach($tests as $needle) {
$accepted = false===strpos($haystack, $needle);
echo $needle, ' ', $accepted ? 'accepted' : 'rejected', "<br />\n";
}