如何通过进行部分字符串匹配来获取字符串的唯一部分

时间:2015-01-28 00:07:14

标签: javascript regex

我需要找出一种方法来通过提供常见的刺痛匹配来获取字符串的一部分。代码设置为: http://jsfiddle.net/rexonms/0s7cgxku/

Javascript
----------

findIds(txt);

var ids = [];
var txt = "And all I need is the fan-page-id-xx and also the fan-page-id-yy but not fan-page."


function findIds(txt){

   var word = txt.match(/fan-page-id/m); //how do I get the ids (xx, yy) from here?
   var id = 'x';
   ids.push(id);
   console.log(ids)
}

0 个答案:

没有答案