【转】Maya Mel – Search String in String
轉自:http://schiho.com/?p=179
Hi,
this is a little script which returns a 0 or 1 if the searched text is in a string. Compared with the match function in mel, this one returns 1 or 0, which is more convenient for my opinion. Furthermore somtimes i get really weired results with the match func().
global proc int ySearch(string $searchWord, string $searchInText){
string $longText = $searchInText;
string $shortText = $searchWord;
int $i = 0;
int $j = 0;
string $searchText = “”;
for($i = 1; $i <= (size($longText)-1); $i++){
for($j = $i; $j <= size($longText); $j++){
$searchText = substring($longText, $i, $j);
//print(” i ” + $i + ” ” + $j + ” j \n”);
if ($searchText == $shortText){
return 1;
//print(“drinnen”);
}
}
}
return 0;
}
//Usage:
ySearch(“where is schiho today?”, “schiho”);
//Result: 1
?
轉載于:https://www.cnblogs.com/fzzl/p/3142410.html
總結
以上是生活随笔為你收集整理的【转】Maya Mel – Search String in String的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PHPCMS V9.3.2用户注册模板中
- 下一篇: 【jQuery小实例】---2自定义动画