有字串 a = '34' b = '123456789',要求定義乙個函式返回b字串中第乙個匹配a字串的下標,不得使用現有的方法 indexof()
兩種解決辦法:
substr() 方法可在字串中抽取從 start
下標開始的指定數目的字元。
const **** = (b, a) => ;
return -1;
};let a = '34';
let b = '12345678'
console.log(****(b, a));
//substr() 方法可在字串中抽取從 start 下標開始的指定數目的字元。
slice() 方法可從已有的陣列中返回選定的元素。
let a = '34';
let b = '12345678'
function select(a, b)
}select(a, b)
// slice() 方法可從已有的陣列中返回選定的元素。
在乙個字串中尋找另外乙個字串
在乙個字串中尋找另外乙個字串 public class text foundit true break test system.out.println foundit?found it didn t find it 該段程式有點難以理解,主要就是if語句的理解,if searchme.charat ...
SQL 判斷乙個字串是否在另外乙個字串中
eg str1 admin str2 1234,123admin,xcxx 比較str1是否在str2中 用常用的charindex,返回肯定是有值的,這裡自己動手寫乙個方法 檢查乙個字串是否在另外乙個字串中數,另外乙個字串元素用,隔開 create function dbo checkstrina...
在乙個字串中查詢另外乙個字串的全排列出現位置
1 在乙個字串中查詢另外乙個字串任意的全排列出現位置。例如 a abcfsfcba b abc 則返回。the des s character must be adjacent public static list integer getindex string res,string des has...