Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Description: regex
Submitted on January 5, 2016 at 08:03 PM

Section 1 (D)

import std.stdio : writeln, writefln;
import std.range : take, array, join;
import std.algorithm : map, filter, splitter;
import std.regex;
import std.datetime;

auto stopTime(alias F)() {
	auto sw = StopWatch(AutoStart.yes);
	// writeln(F("big.txt"));
	writeln(F("big.txt").length);
	sw.stop();
	return sw.peek.msecs;
}

auto search(string pattern)(string file) {
	auto r = ctRegex!(pattern);
  import std.mmfile : MmFile;
  import std.file : getSize;
  auto sz = getSize(file);
  auto mmf = new MmFile(file, MmFile.Mode.read, sz, null);
  //mmfile bug??
  import core.memory : GC;
  GC.addRoot(mmf[].ptr);
  scope(exit){
    GC.removeRoot(mmf[].ptr);
  }
  static auto matchLine(T)(T reg){
    return reg["name"]
      .splitter!(a => a == ' ' || a == ';' || a == '\"')
      .filter!(a => a != """")
      .join(".");
  }
  import std.string : lineSplitter;
  return (cast(string)mmf[])
    .lineSplitter()
    .take(10_000_000)
    .map!(a => a.matchFirst(r))
    .filter!(a => !a.empty)
    .map!(matchLine)
    .array;
}

int main(string[] argv) {
	auto elapsed = stopTime!(search!(r"\{.*(?P<name>Microsoft.*)\|\]"));
	writefln("Elapsed: %s", elapsed);
  return 0;
}