Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (24 sloc) 672 Bytes
<html>
<body>
<script>
var log = "jekalmin 25 male 2014-08-22";
var reg = /(.+)\s(\d+)\s(male|female)\s(\d{4}-\d{2}-\d{2})/;
// ù¹ø° ¹æ¹ý
var name = log.replace(reg, "$1");
var age = log.replace(reg, "$2");
var sex = log.replace(reg, "$3");
var today = log.replace(reg, "$4");
console.log("name : " + name);
console.log("age : " + age);
console.log("sex : " + sex);
console.log("today : " + today);
console.log("================================================");
// µÎ¹ø° ¹æ¹ý
var arr = reg.exec(log);
console.log("name : " + arr[1]);
console.log("age : " + arr[2]);
console.log("sex : " + arr[3]);
console.log("today : " + arr[4]);
</script>
</body>
</html>