正则案例

老弟今天问了我个正则问题:

如图所示的字符串,想要取出每一段中的text和bounds的值;

正则案例_第1张图片

我用js这样实现,不知道是否还有更好的方法:


代码如下:

var patt = new RegExp(//gi);

while ((result = patt.exec(str)) != null)  {

  console.log(RegExp.$2);

  console.log(RegExp.$3);

}

你可能感兴趣的:(正则案例)