• 【转】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 ”);
    if ($searchText == $shortText){
    return 1;
    //print(“drinnen”);
    }

    }

    }
    return 0;
    }

    //Usage:
    ySearch(“where is schiho today?”, “schiho”);

    //Result: 1

  • 相关阅读:
    Redis持久化
    Redis配置文件详解
    Linux
    有图有真相
    Redis五大数据类型
    Redis基本知识
    Mysql主从复制
    Python脚本实现KVM虚机添加磁盘
    JQuery制作环形进度条
    JQuery制作标签
  • 原文地址:https://www.cnblogs.com/fzzl/p/3142410.html
Copyright © 2020-2023  润新知