RegExp

DF deefriend at yahoo.com
Wed Oct 15 15:01:04 PDT 2008


/**
 * RegExp test.
 */
import std.regexp;
import std.stdio;

void main() {
	string someString = "Hello world!";
	auto regExp = new RegExp(r"[wW]orld");
	auto result = regExp.search(someString);
	//int k = regExp.test(someString);
	if (result is null) {
		writefln("Not found!");
	} else {
		writefln("Result:" ~ result[0]);
	}
}

This code never writes the searched part, until we uncomment the line with test() method call, though there is a word matching the pattern. Why?



More information about the Digitalmars-d mailing list