Archive: Q&A

3 JavaScript Regular Expression for Malaysia Data Format

Question

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

  • Identification Card
  • Postcode
  • Phone Number

Continue reading…

Posted in How-To, JavaScript, Q&A, Regular Expression | 10 Comments

Copying JavaScript Object Without Adding Reference

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)

Continue reading…

Posted in How-To, JavaScript, Programming, Q&A, Savvy.UI | 1 Comment

Combining Multiple Table Columns in MySQL

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;

Continue reading…

Posted in Database, How-To, MySQL, Programming, Q&A, Tutorial | 5 Comments