diff --git a/changelog/pattern-deprecate.dd b/changelog/pattern-deprecate.dd index 2fe5214fe66..12bedbeb189 100644 --- a/changelog/pattern-deprecate.dd +++ b/changelog/pattern-deprecate.dd @@ -8,3 +8,57 @@ $(MREF std, regex) and $(MREF std, algorithm). They will be removed from $(MREF std, string) on May 2018. If you still need to use these, please see $(LINK2 https://github.com/dlang/undeaD, undeaD). + +The following are examples of the deprecated functions, and their modern replacements. + +Use $(REF find, std, algorithm, searching) to replace $(REF munch, std, string): +------- +import std.algorithm; +import std.ascii; +import std.string; +import std.utf; + +string s = "\tabc"; + +// old +s.munch(whitespace); + +// new +s = s.find!(a => !isWhite(a)); +------- + +Use $(REF matchFirst, std, regex) to replace $(REF inPattern, std, string): +------- +import std.string; +import std.regex; + +// old +if (inPattern('x', "a-z")) { ... } + +// new +if ("x".matchFirst(regex("[a-z]"))) { ... } +------- + +Use $(REF replaceAll, std, regex) to replace $(REF removechars, std, string): +------- +import std.string; +import std.regex; + +// old +"abc".removechars("a-z"); + +// new +"abc".replaceAll(regex("[a-z]"), ""); +------- + +Use $(REF uniq, std, algorithm, iteration) to replace $(REF squeeze, std, string): +------- +import std.algorithm; +import std.string; + +// old +"hello".squeeze; + +// new +"hello".uniq; +-------