문자열 검색 ( like 검색 )

문자열중 찾으려는 문자열을 포함한 단어를 검색
결과값 : 배열로 검색단어를 리턴
function getMatches(string, regex, index) {
 index || (index = 1); // default to the first capturing group
 var matches = [];
 var match;
 var catchs = [] ;
 while (match = regex.exec(string)) {
 //matches.push(match[index]);
 catchs.push(match[0]) ;
 }
 return catchs;    // array ( xel_1, xel_2, xel_abc )
 //return matches;  // array ( 1,2,abc )
} 

var str = 'xel_1 words xel_2 하하하 xel_abc 무얼찾을려구?' ;
var RegEx = /(?:^|\s)xel_(.*?)(?:\s|$)/g; 
var result = getMatches(str , RegEx , 1) ;