從字串的末尾算起查詢出現位置 InStrRev

2021-09-30 06:21:54 字數 629 閱讀 9559

2.6.2 instrrev函式

也可以使用instrrev函式返回乙個字串在另乙個字串**現的位置,與instr函式不同的是,從字串的末尾算起。其語法為:

instrrev(string1,string2[,[start[,compare])

參 數string1為被查詢的字串,引數string2為要查詢的字串,這兩個引數都是必需的。引數start為可選引數,設定每次查詢開始的位置,若 忽略則使用-1,表示從上乙個字元位置開始查詢。引數compare為可選引數,表示所使用的比較方法,如果忽略則執行二進位制比較。

下面的示例使用了instr函式和instrrev函式,相應的結果不同:

sub test()

dim mystring as string

dim ssearch as string

mystring = "i like the functionality that insstrrev gives"

ssearch = "th"

debug.print instr(mystring, ssearch) '返回8

debug.print instrrev(mystring, ssearch) '返回26

end sub

摘抄自: 

查詢字串中子串出現的所有位置

直接上 方案一用find方法 def find all str1,date,start,end while start end i str1.find date,start,end if i 1 break start i 1 print i str1 好主意。好主意,好主意 start 0 end...

統計字串出現的位置

問題描述 輸入一行標準的c語言程式,統計其中if,while,for出現的位置.從1開始。思考 問題比較簡單,照常規的思路就行,在這因為對關鍵字if,for,while後面肯定都會跟 的,所以只要判斷 前有這些關鍵字就行,這是c語言的標準語法 c源 include include int main ...

查詢出字串中出現最多的字元及其出現的次數

已知乙個字串,編寫函式查詢出該字串中出現最多的字元及其出現的次數。輸入字串str,把str給str sort,對str sort中的字元排序,在str sort中統計每個字元出現的次數並比較輸出最多的 include includeint main 從str sort第二個字元開始,比較字元,是不是...