earthquake changes of std.regexp to come

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Feb 17 13:59:40 PST 2009


Joel C. Salomon wrote:
> bearophile wrote:
>> I agree that the API of regexes in Phobos is not much good, but I think designing a good API for it is quite hard.
> 
> So steal one, rather than invent something new. My suggestion would be
> to expose the DFA object, as in Plan 9’s library (documentation at
> <http://plan9.bell-labs.com/magic/man2html/2/regexp>, implementation at
> <http://plan9.bell-labs.com/sources/plan9/sys/src/libregexp/>,
> discussion and links to a Unix implementation at
> <http://swtch.com/~rsc/regexp/>).
> 
> Simple API:
> • regcomp: Compile a regexp DFA;
> • regexec: Apply it to a string, returning a slice of the string that
> matches the first hit (or an array of slices if parenthesized
> expressions are used); and

s/string/input range/

Also returning a range instead of an array of slices is more flexible.

Andrei



More information about the Digitalmars-d mailing list