티스토리 뷰

참고 url : http://lawrence.ecorp.net/inet/samples/regexp-parse.php

match 된 찿은 경과를 배열 또는 RegExp 로 값을 찿을 수 있습니다.
var str = "/product/detail.html?product_no=14&cate_no=1&display_group=2";
var pre = str.match(/product_no=([0-9]+)/);


alert( RegExp.$1 );  // 14을 반환

function xtractReportType1(data) {
    var array = data.match(/\b[\S]+\b/g);
    return array[5] + " " + array[0] +
            " paint retail price: $" + array[2] + " ea.";
}

function xtractReportType2(data){
    data.match(/^(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\s(\S+)\b/);
    return RegExp.$6 + " " + RegExp.$1 +
            " paint retails for $" + RegExp.$3 + " ea.";
}

댓글
D-DAY
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함