earthquake changes of std.regexp to come
Joel C. Salomon
joelcsalomon at gmail.com
Tue Feb 17 11:51:05 PST 2009
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
• regsub: Apply substitutions to subexpressions of the matching slice.
—Joel Salomon
More information about the Digitalmars-d
mailing list