RegExp.find() now crippled

Steve Teale steve.teale at britseyeview.com
Sun Nov 14 22:58:00 PST 2010


Some time ago in phobos2, the following:

   RegExp wsr = RegExp("(\\s+)");
   int p = wsr.find("<thingie att1=\"whatever\">");
   writefln("%s|%s|%s %d",wsr.pre(),  wsr.match(1), wsr.post(), p);

would print:

<thingie| |att1="whatever"> 7

Now it prints

<thingie| |att1="whatever"> 1

The new return value is pretty useless, equivalent to returning a bool. It seems to me that the 'find' verb's subject should be the string, not the RegExp object.

This looks like a case of the implementation being changed to match the documentation, when in fact it would have been better to change the documentation to match the implementation.

Either that, or RegExp should have an indexOf method that behaves like string.indexOf.

Steve



More information about the Digitalmars-d mailing list