Question about using regex

James Oliphant jollie.roger at gmail.com
Wed Mar 21 09:05:34 PDT 2012


While following the regex discussion, I have been compiling the examples 
to help with my understanding of how it works.

>From Dmitry's example page:
	http://blackwhale.github.com/regular-expression.html
and from the dlang.org website:
	http://dlang.org/phobos/std_regex.html

std.regex.replace calls a delegate
	auto delegate(Captures!string)
which does not compile.  The definition in Phobos for Captures is
	struct Captures(R,DIndex)
and for the purposes of these examples changing the delegate to
	auto delegate(Captures!(string,uint))
seems to work.  Is this correct?


In another example on Dmitry's page that starts:
	auto m = match("Ranges are hot!", r"(\w)\w*(\w)"); //at least 3 
"word" symbols
The output from the example is "Ranges, R, s", but I don't quite 
understand why those where the matches in this case.  Also does the 
regular expression imply match at least 2 "word" symbols where \w* means 
match 0 or more "word" symbols?

These newsgroups are a great resource, keep up the great work!


More information about the Digitalmars-d-learn mailing list