strip()
是 julia 中的一个内置函数,用于从指定的字符串str 中删除前导和尾随字符。这些删除元素由给定的字符chars指定。
Syntax:
strip(str::AbstractString, chars)
Parameters:
- str::AbstractString: Specified string.
- chars: Specified characters.
Returns: It returns a stripped part of the given string.
例子:
# Julia program to illustrate
# the use of strip() method
# Getting a stripped part of the given string.
println(strip("Geeks", ['s']))
println(strip("GFG", ['G']))
println(strip("1 + 2+3 + 4", ['+']))
println(strip("+1 + 2+3 + 4+", ['+']))
输出:
Geek
F
1+2+3+4
1+2+3+4
lstrip()
lstrip()
是 julia 中的一个内置函数,用于从指定的字符串str 中删除前导字符。这些删除元素由给定的字符chars指定。
Syntax:
lstrip(str::AbstractString, chars)
Parameters:
- str::AbstractString: Specified string.
- chars: Specified characters.
Returns: It returns a stripped part of the given string.
例子:
# Julia program to illustrate
# the use of lstrip() method
# Getting a stripped part of the given string.
println(lstrip("Geek", ['G']))
println(lstrip("GFG", ['G']))
println(lstrip("1 + 2+3 + 4+", ['+']))
println(lstrip("+1 + 2+3 + 4", ['+']))
输出:
eek
FG
1+2+3+4+
1+2+3+4
rstrip()
rstrip()
是 julia 中的一个内置函数,用于从指定的字符串str 中删除尾随字符。这些删除元素由给定的字符chars指定。
Syntax:
rstrip(str::AbstractString, chars)
Parameters:
- str::AbstractString: Specified string.
- chars: Specified characters.
Returns: It returns a stripped part of the given string.
例子:
# Julia program to illustrate
# the use of rstrip() method
# Getting a stripped part of the given string.
println(rstrip("Geek", ['G']))
println(rstrip("GFG", ['G']))
println(rstrip("1 + 2+3 + 4+", ['+']))
println(rstrip("+1 + 2+3 + 4", ['+']))
输出:
Geek
GF
1+2+3+4
+1+2+3+4