📌  相关文章
📜  在 Julia 中查找字符串中上一次出现的模式 – findprev() 方法

📅  最后修改于: 2022-05-13 01:55:49.241000             🧑  作者: Mango

在 Julia 中查找字符串中上一次出现的模式 – findprev() 方法

findprev()是 julia 中的一个内置函数,用于返回从指定位置开始在指定字符串中指定模式的上一次出现。

示例 1:

# Julia program to illustrate 
# the use of String findprev() method
   
# Here the pattern is "g", String is
# "geeks" and position is 3
Println(findprev("g", "geeks", 3))
  
# Here the pattern is "G", String is
# "GeeksforGeeks" and position is 10
Println(findprev("G", "GeeksforGeeks", 10))
  
# Here the pattern is "for", String is
# "GeeksforGeeks" and position is 8
Println(findprev("for", "GeeksforGeeks", 8))
  
# Here the pattern is "k", String is
# "GeeksforGeeks" and position is 7
Println(findprev("k", "GeeksforGeeks", 7))

输出:

示例 2:

# Julia program to illustrate 
# the use of String findprev() method
   
# Here the pattern is "23", String is
# "12345" and position is 5
Println(findprev("23", "12345", 5))
  
# Here the pattern is "23", String is
# "12345" and position is 4
Println(findprev("23", "12345", 4))
  
# Here the pattern is "3", String is
# "123123" and position is 6
Println(findprev("3", "123123", 6))
  
# Here the pattern is "123", String is
# "123123123" and position is 7
Println(findprev("123", "123123123", 7))

输出: