Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Regex group bug?

Moderators: kris

Posted: 05/09/08 09:47:01

I cannot get groups to work at all.

Se this simple example:

	char[] txt = "asdf@1234";
	auto r = Regex("^([a-z]+)@([0-9]+)$");
	char[] txt = "asdf@1234";
	auto r = Regex("^([a-z]+)@([0-9]+)$");

	r.test(txt);
	Stdout.formatln("Pre: {} Match(0): {} Post: {}",
			r.pre, r.match(0), r.post);

	Stdout.formatln("Split: {}", r.split(txt));

Output:

Pre:  Match(0): asdf@1234 Post:
Split: [ ,  ]

I would have thought I could loop through the matches and get:

Pre:  Match(0): asdf Post: @1234
Pre: asdf@ Match(1): 1234 Post: 

There are no responses to display.