findnext()是 julia 中的一个内置函数,用于返回从指定位置开始的指定字符串指定模式的下一次出现。
句法:
findnext(pattern::AbstractString, string::AbstractString, start::Integer)
参数:
- pattern::AbstractString:指定的模式
- 字符串::AbstractString:指定的字符串
- start::Integer:它是要执行匹配的起始位置。
返回:它返回从指定位置开始的指定字符串指定模式的下一次出现。示例 1:
Python
# Julia program to illustrate
# the use of String findnext() method
# Here the pattern is "g", String is
# "geeks" and position is 1
Println(findnext("g", "geeks", 1))
# Here the pattern is "G", String is
# "GeeksforGeeks" and position is 6
Println(findnext("G", "GeeksforGeeks", 6))
# Here the pattern is "e", String is
# "GeeksforGeeks" and position is 5
Println(findnext("G", "GeeksforGeeks", 5))
# Here the pattern is "k", String is
# "GeeksforGeeks" and position is 2
Println(findnext("G", "GeeksforGeeks", 2))
Python
# Julia program to illustrate
# the use of String findnext() method
# Here the pattern is "23", String is
# "12345" and position is 1
Println(findnext("23", "12345", 1))
# Here the pattern is "23", String is
# "12345" and position is 2
Println(findnext("23", "12345", 2))
# Here the pattern is "3", String is
# "12345" and position is 5
Println(findnext("3", "12345", 5))
# Here the pattern is "123", String is
# "123123123" and position is 4
Println(findnext("123", "123123123", 4))
输出:
示例 2:
Python
# Julia program to illustrate
# the use of String findnext() method
# Here the pattern is "23", String is
# "12345" and position is 1
Println(findnext("23", "12345", 1))
# Here the pattern is "23", String is
# "12345" and position is 2
Println(findnext("23", "12345", 2))
# Here the pattern is "3", String is
# "12345" and position is 5
Println(findnext("3", "12345", 5))
# Here the pattern is "123", String is
# "123123123" and position is 4
Println(findnext("123", "123123123", 4))
输出: