RosettaCodeData/Task/Regular-expressions/D/regular-expressions.d

13 lines
235 B
D
Raw Permalink Normal View History

2013-04-10 23:57:08 -07:00
void main() {
2014-04-02 16:56:35 +00:00
import std.stdio, std.regex;
immutable s = "I am a string";
2013-04-10 23:57:08 -07:00
2014-04-02 16:56:35 +00:00
// Test.
2015-02-20 00:35:01 -05:00
if (s.match("string$"))
2014-04-02 16:56:35 +00:00
"Ends with 'string'.".writeln;
2013-04-10 23:57:08 -07:00
2014-04-02 16:56:35 +00:00
// Substitute.
s.replace(" a ".regex, " another ").writeln;
2013-04-10 23:57:08 -07:00
}