I'm trying 'port' a register page from php into c# and I'm currently facing this issue:
if(ereg("^[0-9a-zA-Z]{12,12}$",$_GET["password"])) $code = ''; {
}
if(ereg("^[0-9a-zA-Z]{13,13}$",$_GET["password"])) $code = ''; {
}
if(ereg("^[0-9a-zA-Z]{14,14}$",$_GET["password"])) $code = ''; {
}
I can't understand what does it checks in the regex and what's with the character in the variable $code ( I mean , what kind of character it is so I can add the same character in c#)
The ^
at the start of a RegEx means that the regular expression HAS to start with whatever comes next.
Everything between [
and ]
are you you are matching. In your case, the number 0
to 9
, and the letter a
through z
, both capital and lower case.
The numbers inside {}
means minimum and maximum length. So your first one has the be exactly 12 characters long.
The $
at the end means that is the end of the line.
All in all, each RegEx means that it can ONLY have alpha-numeric characters, and the length is different for each.