findnext() 是 julia 中的一个内置函数,用于返回从指定位置开始的指定字符串中指定模式的下一次出现。
用法:
findnext(pattern::AbstractString, string::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))
输出:
范例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))
输出:
相关用法
- Julia Array findnext()用法及代码示例
- Julia findprev()用法及代码示例
- Julia findlast()用法及代码示例
- Julia findfirst()用法及代码示例
- Julia string()用法及代码示例
- Julia sizeof()用法及代码示例
- Julia reverse()用法及代码示例
- Julia length()用法及代码示例
- Julia repeat()用法及代码示例
- Julia SubString()用法及代码示例
- Julia replace()用法及代码示例
- Julia startswith()用法及代码示例
- Julia endswith()用法及代码示例
- Julia first()用法及代码示例
- Julia last()用法及代码示例
- Julia join()用法及代码示例
注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 Find the next occurrence of pattern in string in Julia – findnext() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。