Link to home
Start Free TrialLog in
Avatar of ncw
ncw

asked on

Syntax used with ereg

Could someone explain the following code in English please:

$validFormat = ereg("^(3[0-9]{4}|2131|1800)[0-9]{11}$", $this->__ccNum);

The code is validating a JCB type credit card number. I've read an explanation for the function ereg at http://www.phpbuilder.com/manual2/manual/fi/function.ereg.php , but I'm looking for a bit more help.

eg how does this work: "^(3[0-9]{4}|2131|1800)[0-9]{11}$"
what does ^ mean?
I think | = or

The valid format for JCB is:
1. prefix = 3 and lenght = 16 or
2. prefix = 2131 or 1800 and length = 15
ASKER CERTIFIED SOLUTION
Avatar of HaydnH
HaydnH

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial