자주쓰는 정규식

/* 핸드폰 번호 Dash 표현 */
var tel = "01012345678".replace(/(\d{3})(\d{4})(\d{4})/g, "$1-$2-$3");
console.log( "TEL : "+tel );
// TEL : 010-1234-5678

/* 핸드폰 번호 확인 */
var regExp = /^\d{3}-\d{3,4}-\d{4}$/;
console.log( "PHONE : "+regExp.test("010-1234-5678") );
// PHONE : true

/* 이메일 확인 */
var regExp = /^[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*@[0-9a-zA-Z]([-_\.]?[0-9a-zA-Z])*\.[a-zA-Z]{2,3}$/i; 
console.log( "E-mail: "+regExp.test("uznam8x@gmail.com") );
// E-mail : true

URL QueryString 가져오기

function request(){
	var queryString = {};
	window.location.search.replace(
		new RegExp("([^?=&]+)(=([^&]*))?", "g"), function($0, $1, $2, $3) { 
			queryString[$1] = $3;
		}
	);
	return queryString;
}

// http://www.domain.com?foo=111&fruit=apple
console.log( requeset() );
// { foo:111, fruit:apple }

Guid 와 Uuid 만들기

function guid() {
	function s4() {
		return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
	}
	return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}

console.log("GUID : "+guid());
// GUID : b65fad31-275a-2501-32e5-832f9075abc5

function uuid(){
	var d = new Date().getTime();
	if(window.performance && typeof window.performance.now === "function"){
		d += performance.now();
	}
	return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
		var r = (d + Math.random()*16)%16 | 0;
		d = Math.floor(d/16);
		return (c=='x' ? r : (r&0x3|0x8)).toString(16);
	});
}
console.log("UUID : "+uuid());
// UUID : 92bea031-b9c2-4b4a-ac81-0e005e2d0e88