View source code
Display the source code in std/string.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.string.chompPrefix
If str
starts with delimiter
, then the part of str
following
delimiter
is returned. If str
does not start with
Range chompPrefix(Range, C2)
(
Range str,
const(C2)[] delimiter
)
if ((isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) || isNarrowString!Range) && !isConvertibleToString!Range && isSomeChar!C2);
delimiter
, then it is returned unchanged.
Parameters
Name | Description |
---|---|
str | string or forward range of characters |
delimiter | string of characters to be sliced off front of str[] |
Returns
slice of str
Example
writeln(chompPrefix("hello world", "he")); // "llo world"
writeln(chompPrefix("hello world", "hello w")); // "orld"
writeln(chompPrefix("hello world", " world")); // "hello world"
writeln(chompPrefix("", "hello")); // ""
Authors
Walter Bright, Andrei Alexandrescu, Jonathan M Davis, and David L. 'SpottedTiger' Davis
License
Copyright © 1999-2024 by the D Language Foundation | Page generated by ddox.