Page is a not externally linkable
lucy24 - 6:10 am on Jul 2, 2012 (gmt 0)
If someone else were posting this question, the answer would jump right up and hit me in the face. But it's my own problem, so I'm overlooking something embarrassingly obvious.
expr = /((\[\d\d\/\w\w\w)\/20\d\d:(\d\d):\d\d:\d\d .+\n)\n([\d.]+ - - (\[\d\d\/\w\w\w)\/20\d\d:(\d\d))/m;
do
{
extra = "";
flag = expr.test(output);
if (flag != false)
{
day1 = expr.exec(output)[2];
day2 = expr.exec(output)[5];
hour1 = parseInt(expr.exec(output)[3]);
hour2 = parseInt(expr.exec(output)[6]);
if (day1 != day2)
{ extra = "\nDATE\n\n"; }
if (hour1 < 6 && hour2 >= 6)
{ extra = "\n<tbody class = \"day\">\n"; }
if (hour1 < 15 && hour2 >= 15)
{ extra = "<\/tbody>\n\n"; }
output = output.replace(expr,"$1" + extra + "$4");
}
}
while (flag != false);
All of this works as intended. No false positives, no false negatives... EXCEPT that when hour1 = 9 and hour2 = 10, it thinks the second condition has been met and shoves in an extraneous <tbody...> line.
What, please, am I overlooking? :(
In case anyone wondered: The code was written for a specific situation, so the three conditions are de facto mutually exclusive. I run it locally and the text blocks aren't very big. So twiddling my thumbs while javascript does its stuff is definitely preferable to learning yet another language ;)