Degenerate Regex Case

Guillaume via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 24 11:28:15 PDT 2015


Hello, I'm trying to make a regex comparison with D, based off of 
this article: https://swtch.com/~rsc/regexp/regexp1.html

I've written my code like so:

import std.stdio, std.regex;

void main(string argv[]) {

	string m = argv[1];
	auto p = 
ctRegex!("a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?a?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
	if (match(m, p)) {
		writeln("match");
	} else {
		writeln("no match");
	}

}

And the compiler goes into swap. Doing it at runtime is no 
better. I was under the impression that this particular regex was 
used for showcasing the Thompson NFA which D claims to be using.

The golang code version of this runs fine, which makes me think 
that maybe D isn't using the correct regex engine for this 
particular regex. Or perhaps I'm using this wrong?


More information about the Digitalmars-d-learn mailing list