On Tue, Mar 17, 2009 at 10:54 AM, Paolo Invernizzi <arath...@fastwebnet.iit> wrote: > Hi all, > Someone can point me to a way of doing something like this with DMD 2.026: > > class A { > invariant(int) rev = std.conv.to!(int)("$Rev: 182 $"); > } > > I've messed up with metastrings and std.conv, but I cannot find a working way. > > Cheers, Paolo >
int parseRevision(string s) { // I'm assuming it'll always be of the form "\$ Rev: (\d+) \$" return to!(int)(s["$ Rev: ".length .. $ - 2]); } void main() { immutable(int) x = parseRevision("$ Rev: 182 $"); writefln(x); }