检查字符串是否以 Julia 中的指定前缀开头 - startswith() 方法
startswith()
是 julia 中的内置函数,如果指定的字符串以指定的前缀开头,则用于返回 true,否则返回 false。
Syntax:
startswith(s::AbstractString, prefix::AbstractString)
Parameters:
- s::AbstractString: Specified string.
- prefix::AbstractString: Specified prefix value.
Returns: It returns true if the specified string start with the specified prefix else return false.
示例 1:
# Julia program to illustrate
# the use of String startswith() method
# Checking starting part of string with
# specified prefix value
println(startswith("Geeks", "Geek"))
println(startswith("GeeksforGeeks", "G"))
println(startswith("GFG", "GFG"))
输出:
true
true
true
示例 2:
# Julia program to illustrate
# the use of String startswith() method
# Checking starting part of string with
# specified prefix value
println(startswith("Geeks", "ks"))
println(startswith("GeeksforGeeks", "forGeeks"))
println(startswith("GFG", "gfg"))
输出:
false
false
false