我一直在关注regex101和SO,但无法弄清楚我做错了什么。
我有一个多行字符串,如:
23.
Martin K, Thompson KG, Keegan R, Ball N, Rattray B. Mental fatigue does not mid:25425259.
View Article
我希望在23.
和"View Article"
字符串之间提取所有内容。
此正则表达式(已启用多行):
\d{1,2}.([^?V]*)
完成工作,但如果V
在View...
中出现"View Article"
之前就失败了。
换句话说,我认为我正在寻找一个积极的多线预测,直到<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="content-type" content="text/html; charset=UTF8">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"
type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="dc.css" media="screen" />
<title>Dc Tutorial</title>
<script type="text/javascript" src="crossfilter.js"></script>
<script type="text/javascript" src="d3.min.js"></script>
<script type="text/javascript" src="dc.js"></script>
<script type="text/javascript">
var ndx;
var data = [
{date: "12/27/2012", http_404: 2, http_200: 190, http_302: 100},
{date: "12/28/2012", http_404: 2, http_200: 10, http_302: 100},
{date: "12/31/2012", http_404: 2, http_200: 90, http_302: 0},
{date: "01/01/2013", http_404: 2, http_200: 90, http_302: 0},
{date: "01/02/2013", http_404: 1, http_200: 10, http_302: 1},
{date: "01/03/2013", http_404: 2, http_200: 90, http_302: 0},
{date: "01/04/2013", http_404: 2, http_200: 90, http_302: 0}
];
var data2 = [
{date: "12/29/2012", http_404: 1, http_200: 300, http_302: 200},
{date: "12/30/2012", http_404: 2, http_200: 90, http_302: 0},
{date: "01/05/2013", http_404: 2, http_200: 90, http_302: 0},
{date: "01/06/2013", http_404: 2, http_200: 200, http_302: 1},
{date: "01/07/2013", http_404: 1, http_200: 200, http_302: 100}
];
function renderChart(){
var hitslineChart = dc.lineChart("#chart-line-hitsperday");
ndx = crossfilter(data);
var parseDate = d3.time.format("%m/%d/%Y").parse;
data.forEach(function(d) {
d.date = parseDate(d.date);
d.total= d.http_404+d.http_200+d.http_302;
d.Year=d.date.getFullYear();
});
var dateDim = ndx.dimension(function(d) {return d.date;});
var hits = dateDim.group().reduceSum(function(d) {return d.total;});
var minDate = dateDim.bottom(1)[0].date;
var maxDate = dateDim.top(1)[0].date;
hitslineChart
.width(500).height(200)
.dimension(dateDim)
.group(hits)
.x(d3.time.scale().domain([minDate,maxDate]))
.brushOn(false)
.yAxisLabel("Hits per day");
var yearRingChart = dc.pieChart("#chart-ring-year");
var yearDim = ndx.dimension(function(d) {return +d.Year;});
var year_total = yearDim.group().reduceSum(function(d) {return d.http_200+d.http_302;});
yearRingChart
.width(150).height(150)
.dimension(yearDim)
.group(year_total)
.innerRadius(30);
dc.renderAll();
}
function addData(){
console.log('adding data2 to ndx');
ndx.add(data2);
dc.redrawAll();
}
</script>
</head>
<body>
<div id="chart-ring-year"></div>
<div id="chart-line-hitsperday"></div>
<button onclick="addData()">Add Data</button>
<script>
renderChart();
</script>
</body>
</html>
。
以下是我正在做的事情的演示:regex101 demo