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.detabber
Replace each tab character in r
with the number of spaces
necessary to align the following character at the next tab stop.
auto detabber(Range)
(
Range r,
size_t tabSize = 8
)
if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) && !isConvertibleToString!Range);
Parameters
Name | Description |
---|---|
r | string or forward range |
tabSize | distance between tab stops |
Returns
lazy forward range with tabs replaced with spaces
Example
import std .array : array;
writeln(detabber(" \n\tx", 9) .array); // " \n x"
Example
import std .array : array;
import std .utf : byChar, byWchar;
writeln(detabber(" \u2029\t" .byChar, 9) .array); // " \u2029 "
auto r = "hel\tx" .byWchar .detabber();
writeln(r .front); // 'h'
auto s = r .save;
r .popFront();
r .popFront();
writeln(r .front); // 'l'
writeln(s .front); // 'h'
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.