June 01, 2013
I have some D2 source code resembling

  if (auto m = std.regexp.search(text, "x") )  {
      ...
  }

This gives "function std.regexp.search is deprecated".  Not being expert at regexes in any compile-to-metal language including D, I hoped I could just change "regexp" to "regex" and be on my way.  Nope, apparently the new regex isn't pin-for-pin compatible with the old regexp.  It doesn't have search().  The compiler gives "Error: undefined identifier module regex.search"

Not wanting to spend a gob of time learning regex, which I'm unlikely to ever use in my normal work (or abnormal work), is there something like a how-to cheat sheet for switching regexp code to regex?


June 01, 2013
On 6/1/13 6:31 PM, Daren Scot Wilson wrote:
> I have some D2 source code resembling
>
>    if (auto m = std.regexp.search(text, "x") )  {
>        ...
>    }
>
> This gives "function std.regexp.search is deprecated".  Not being expert
> at regexes in any compile-to-metal language including D, I hoped I could
> just change "regexp" to "regex" and be on my way. Nope, apparently the
> new regex isn't pin-for-pin compatible with the old regexp.  It doesn't
> have search().  The compiler gives "Error: undefined identifier module
> regex.search"
>
> Not wanting to spend a gob of time learning regex, which I'm unlikely to
> ever use in my normal work (or abnormal work), is there something like a
> how-to cheat sheet for switching regexp code to regex?
>
>

The details of std.regex is found at this link:
	http://dlang.org/phobos/std_regex.html

maybe this might help:

import std.regex;
void main() {
	auto text = "regex";
	if (auto m = match(text, "x") )  {
	        auto c = m.captures;
	        writeln(c.pre, ":", c.post, ":", c.hit);
	}
}

For future information, posts of this nature should be posted in D.learn.

-- 

Andrew Edwards
--------------------
http://www.akeron.co
auto getAddress() {
    string location = "@", period = ".";
    return ("info" ~ location ~ "afidem" ~ period ~ "org");
}