转自: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

【转】Maya Mel – Search String in String的更多相关文章

  1. csharp:search and Compare string

    /// <summary> /// 涂聚文 /// 2011 捷为工作室 /// 缔友计算机信息技术有限公司 /// </summary> /// <param name ...

  2. Maya mel maya档出现未知插件解决方法

    Maya mel maya档出现未知插件解决方法 以下 mel 代码,拷贝到 maya 的脚本编辑器的 mel 中,最好运行两次 string $unknownNodes[] = `ls -type ...

  3. [C#] string 与 String,大 S 与小 S 之间没有什么不可言说的秘密

    string 与 String,大 S 与小 S 之间没有什么不可言说的秘密 目录 小写 string 与大写 String 声明与初始化 string string 的不可变性 正则 string ...

  4. java.lang.String.getBytes(String charsetName)方法实例

    java.lang.String.getBytes(String charsetName) 方法编码将此String使用指定的字符集的字节序列,并将结果存储到一个新的字节数组. 声明 以下是java. ...

  5. Lua的string和string库总结

    Lua有7种数据类型,分别是nil.boolean.number.string.table.function.userdata.这里我总结一下Lua的string类型和string库,复习一下,以便加 ...

  6. C#,int转成string,string转成int

    转载:http://www.cnblogs.com/xshy3412/archive/2007/08/29/874362.html 1,int转成string用toString 或者Convert.t ...

  7. C#中对string与string[]的初步操作

    开篇之作,简单的对string与string[]进行初步操作,入门篇也,不多说,直接上代码. using System; using System.Collections.Generic; using ...

  8. Java提高篇——理解String 及 String.intern() 在实际中的应用

    1. 首先String不属于8种基本数据类型,String是一个对象.   因为对象的默认值是null,所以String的默认值也是null:但它又是一种特殊的对象,有其它对象没有的一些特性. 2. ...

  9. [C#]List<int>转string[],string[]转为string

    // List<int>转string[] public string[] ListInt2StringArray(List<int> input) { return Arra ...

随机推荐

  1. 使用new Image()进行预加载

    概述 这篇博文记录了用new Image()进行预加载的总结,供以后开发时参考,相信对其他人也有用. 旧的预加载 一般我们为了让背景图更快的加载,我们常常把背景图放在一个display:none的im ...

  2. iOSAPP开发项目搭建

    架构图: 架构原则:易读性.易维护性.易扩展性. 一.思考 做好一件事,花在思考上的时间应该多于执行. 首先根据产品需求和设计图,脑中先建立一个产品架构: 1. 产品的定位是什么. 社交?媒体?游戏? ...

  3. spring boot -thymeleaf-日期转化

    <span th:text="${#dates.format(date)}" ></span><span th:text="${#dates ...

  4. 记hangfire后台任务运行一段时间后不运行了。

    什么是Hangfire Hangfire 是一个开源的.NET任务调度框架,目前1.6+版本已支持.NET Core.个人认为它最大特点在于内置提供集成化的控制台,方便后台查看及监控. https:/ ...

  5. Cannot determine embedded database driver class for database type NONE

    springboot+jpa使用自定义配置文件连接数据库报错:Cannot determine embedded database driver class for database type NON ...

  6. 课程四(Convolutional Neural Networks),第三 周(Object detection) —— 2.Programming assignments:Car detection with YOLOv2

    Autonomous driving - Car detection Welcome to your week 3 programming assignment. You will learn abo ...

  7. spring cloud+.net core搭建微服务架构:配置中心(四)

    前言 我们项目中有很多需要配置的地方,最常见的就是各种服务URL地址,这些地址针对不同的运行环境还不一样,不管和打包还是部署都麻烦,需要非常的小心.一般配置都是存储到配置文件里面,不管多小的配置变动, ...

  8. 从零开始学 Web 之 BOM(二)定时器

    大家好,这里是「 从零开始学 Web 系列教程 」,并在下列地址同步更新...... github:https://github.com/Daotin/Web 微信公众号:Web前端之巅 博客园:ht ...

  9. PHP-CPP开发扩展(四)

    PHP-CPP是一个用于开发PHP扩展的C++库.本节讲解如何在C++中调用PHP函数. 调用PHP函数 调用普通函数 // call a function from user space Php:: ...

  10. leetcode — merge-k-sorted-lists

    import java.util.ArrayList; import java.util.List; import java.util.PriorityQueue; /** * Source : ht ...