Posts in:
string

Don’t Hard Code Your Age!

Even though this is not at all as important as not hardcoding copyright years. It can still a time saver if you happen to hard code your age into a biography on a website.

Validate a Credit Card Number

This code snippet is a regular expression which checks or validates a credit card number.
The Expression: ^([0-9]{4})[\-|\s]*([0-9]{4})[\-|\s]*([0-9]{4})[\-|\s]*([0-9]{2,4})$

Validate a Phone Number

This code snippet is a regular expression which checks or validates a phone number.
The Expression: ^[\+]?([0-9]?)[\(|\s|\-|\.]?([0-9]{3})[\)|\s|\-|\.]*([0-9]{3})[\s|\-|\.]*([0-9]{4})$

Limit Words in a String

While developing websites, I’ve frequently run into clients who would like a news system integrated on their site. A news system consists of a list of articles, usually a summary at first, and when an article has been selected, the full article is displayed. So, how do you extract the summary from the content without [...]