3 JavaScript Regular Expression for Malaysia Data Format

Posted on the September 17th, 2008 under JavaScript, Programming, Q&A, Tutorial by Zaki

Question

Can you share with us the proper Regular Expression (RegExp) for Malaysia’s data format as the following:

  • Identification Card
  • Postcode
  • Phone Number

Copying JavaScript Object Without Adding Reference

Posted on the August 28th, 2008 under JavaScript, Programming, Q&A, Savvy.UI by Zaki

Question

How to copy a JavaScript Object without adding the reference to the object it copy from? For example:

var user = {
	name: "Mior Muhammad Zaki",
	age: 25
};
var programmer = user;
programmer.language = ["PHP", "MySQL", "JavaScript"];
alert(user.language);
// return ["PHP", "MySQL", "JavaScript"] (when expect undefined)

Combining Multiple Table Columns in MySQL

Posted on the August 25th, 2008 under MySQL, Programming, Q&A, Tutorial by Zaki

Question

How to combine address1, address2, address3 and address4 in the following table to a single column such as address?

CREATE TABLE user (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 255 ) NOT NULL ,
`email` VARCHAR( 255 ) NOT NULL ,
`address1` VARCHAR( 100 ) NOT NULL ,
`address2` VARCHAR( 100 ) NOT NULL ,
`address3` VARCHAR( 100 ) NOT NULL ,
`address4` VARCHAR( 100 ) NOT NULL ,
`postcode` VARCHAR( 6 ) NOT NULL ,
`state` VARCHAR( 100 ) NOT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM;