Remove end characters from strings in Julia – strip(), lstrip() and rstrip() Methods
Last Updated :
01 Apr, 2020
The strip()
is an inbuilt function in julia which is used to remove leading and trailing characters from the specified string str. These removing elements is specified by given characters chars.
Syntax:
strip(str::AbstractString, chars)
Parameters:
- str::AbstractString: Specified string.
- chars: Specified characters.
Returns: It returns a stripped part of the given string.
Example:
println(strip( "Geeks" , [ 's' ]))
println(strip( "GFG" , [ 'G' ]))
println(strip( "1 + 2+3 + 4" , [ '+' ]))
println(strip( "+1 + 2+3 + 4+" , [ '+' ]))
|
Output:
Geek
F
1+2+3+4
1+2+3+4
lstrip()
The lstrip()
is an inbuilt function in julia which is used to remove leading characters from the specified string str. These removing elements is specified by given characters chars.
Syntax:
lstrip(str::AbstractString, chars)
Parameters:
- str::AbstractString: Specified string.
- chars: Specified characters.
Returns: It returns a stripped part of the given string.
Example:
println(lstrip( "Geek" , [ 'G' ]))
println(lstrip( "GFG" , [ 'G' ]))
println(lstrip( "1 + 2+3 + 4+" , [ '+' ]))
println(lstrip( "+1 + 2+3 + 4" , [ '+' ]))
|
Output:
eek
FG
1+2+3+4+
1+2+3+4
rstrip()
The rstrip()
is an inbuilt function in julia which is used to remove trailing characters from the specified string str. These removing elements is specified by given characters chars.
Syntax:
rstrip(str::AbstractString, chars)
Parameters:
- str::AbstractString: Specified string.
- chars: Specified characters.
Returns: It returns a stripped part of the given string.
Example:
println(rstrip( "Geek" , [ 'G' ]))
println(rstrip( "GFG" , [ 'G' ]))
println(rstrip( "1 + 2+3 + 4+" , [ '+' ]))
println(rstrip( "+1 + 2+3 + 4" , [ '+' ]))
|
Output:
Geek
GF
1+2+3+4
+1+2+3+4
Share your thoughts in the comments
Please Login to comment...