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