有这样一个txt文本,http://106.54.21.221/result.txt
请用utf-8读取。
我想截取其中的:
第一个:
【签到号一】: 快乐的小猪哥
【签到概览】: 失败38个
【账号总计】: 55105京豆, 1.02钢镚
【其他总计】: 0.40金贴, 4.37现金
第二个:
【签到号二】: 新华2088
【签到概览】: 失败38个
【账号总计】: 31京豆, 0.02钢镚
【其他总计】: 0.04金贴, 0.55现金, 0.11红包
以后可能还有第三个、第四个。。。。
这里头的下面参数是固定的。
【签到号一】: 快乐的小猪哥
【签到号二】: 新华2088
谢谢。
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7,chrome=1" />
<title>demo</title>
</head>
<body>
<script type="text/javascript" src="http://libs.baidu.com/jquery/1.11.1/jquery.min.js"></script>
<script>
$.ajax({
url: "http://106.54.21.221/result.txt",
type: "get",
dataType: "text",
success: function (data) {
var arr = data.match(/【签到号[\s\S]+?【其他总计】.+/ig);
if (arr)
arr.forEach(function(v){
console.log(v);
});
else
console.log("没有找到");
},
error: function (jqXHR, status, thrown) {
alert("错误 :"+thrown);
}
});
</script>
</body>
</html>
浏览器直接那个txt,请改成utf8编码。
以这个”【签到号“ 分割一下不就行嘛