Monday, August 20, 2012

PHP Regular Expressions

Source: http://www.roscripts.com/PHP_regular_expressions_examples-136.html


//Credit card: All major cards
'^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6011[0-9]{12}|3(?:0[0-5]|[68][0-9])[0-9]{11}|3[47][0-9]{13})$'

//Credit card: American Express
'^3[47][0-9]{13}$'

//Credit card: Diners Club
'^3(?:0[0-5]|[68][0-9])[0-9]{11}$'

//Credit card: Discover
'^6011[0-9]{12}$'

//Credit card: MasterCard
'^5[1-5][0-9]{14}$'

//Credit card: Visa
'^4[0-9]{12}(?:[0-9]{3})?$'

//Credit card: remove non-digits
'/[^0-9]+/'

Online Regular Expression Checker
http://gskinner.com/RegExr/

http://cybernetnews.com/online-regular-expression-builder/

No comments:

Post a Comment

About

Blogger templates