Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions changelog/pattern-deprecate.dd
Original file line number Diff line number Diff line change
Expand Up @@ -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;
-------