There are lots of language structures and inbuilt functions in the D programming language that we can use. In this shot, we will take a look at the strip()
method.
strip()
method?The strip()
method will remove element_value
from the range_value
and return the range with the lement removed.
strip(range_value,element_value)
range_value
: This is a range
variable that can either be an array or a tuple.
element_value
: The element that will be stripped of the range_value
. All occurrences of this value will be removed.
The value returned is a range_value
with all occurrences of element_value
removed.
The code snippet below demonstrates the usage of the strip()
method.
import std.stdio; import std.algorithm.mutation; //start the main wrapper function void main() { writeln(strip(" Hello welcome to eductative ",' ')); writeln(strip("11456.67899511",'1')); writeln(strip("ëëêéüŗōpéêëë",'ë')); writeln(strip([1, 1, 0, 1, 1],1)); //return the length of strip variable writeln(strip([01.0, 0.04, 0.06, 0.0],0).length); }
writeln
to import the stdio
module.std.algorithm.mutation
module which holds the strip()
method.main
function which returns nothing, such as void
.writeln
method to print to screen the output of the strip()
method..length
property of arrays in D language to return the length of the stripped value.RELATED TAGS
CONTRIBUTOR
View all Courses