检查字符串是否以 Julia 中的指定后缀结尾 - endswith() 方法
endswith()
是 julia 中的一个内置函数,如果指定的字符串以指定的后缀值结尾则返回 true,否则返回 false。
Syntax:
endswith(s::AbstractString, suffix::AbstractString)
Parameters:
- s::AbstractString: Specified string.
- suffix::AbstractString: Specified suffix value.
Returns: It returns true if the specified string ends with the specified suffix else return false.
示例 1:
# Julia program to illustrate
# the use of String endswith() method
# Checking ending part of string with
# specified suffix value
println(endswith("Geeks", "ks"))
println(endswith("GeeksforGeeks", "forGeeks"))
println(endswith("GFG", "FG"))
输出:
true
true
true
示例 2:
# Julia program to illustrate
# the use of String endswith() method
# Checking ending part of string with
# specified suffix value
println(endswith("Geeks", "Geek"))
println(endswith("GeeksforGeeks", "Geek"))
println(endswith("GFG", "GF"))
输出:
false
false
false