转自: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相关推荐

  1. maya mel uf8_MAYA MEL问题

    展开全部 choice 就是一个 Mel 命令,具体用法看32313133353236313431303231363533e58685e5aeb931333238653861Help去,以下是Help ...

  2. static string java_java:String类、static关键字、Arrays类、 Math类

    public voidStrMethodTest(){/** public int length () :返回此字符串的长度. * public String concat (String str) ...

  3. 转换ArrayList String 到String []数组[重复]

    本文翻译自:Convert ArrayList to String[] array [duplicate] This question already has an answer here: 这个问题 ...

  4. C#中的String和string有什么区别?还有ref关键字怎么用?

    String 和 string 没有区别 string 是 String 的别名 ref 关键字一般只用于函数参数中,这个参数是 struct 类型,而不是 class 类型 因为 class 类型在 ...

  5. shell中$后加引号有什么用($string和$'string')

    bash&shell系列文章:http://www.cnblogs.com/f-ck-need-u/p/7048359.html 有些时候在某些服务管理脚本中看到$"$string& ...

  6. 【错误记录】Kotlin 编译报错 ( Type mismatch: inferred type is String? but String was expected )

    文章目录 一.报错信息 二.解决方案 一.报错信息 Google Play 上架要求 Android 的编译版本 和 目标版本都要高于 30 才可以上传 ; 将 Android 的编译版本 和 目标版 ...

  7. C#String与string大小写的区别

    1.string是c#中的类,String是.net Framework的类(在c# IDE中不会显示蓝色)   2.C# string映射为.net Framework的String   3.如果用 ...

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

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

  9. python timeit class Timer()类 timeit(string, string) repeat(string, string) default_timer() 耗时检测 执行速度

    #! /usr/bin/env python3"""Tool for measuring execution time of small code snippets. 用 ...

最新文章

  1. mysql数据库优化命令_MySQL数据库优化总结
  2. 人工智能:AI 芯片快速起航
  3. 统一沟通-技巧-11-Lync-联盟-1-MSN
  4. [Node.js]常用工具
  5. 步步为营(十六)搜索(二)BFS 广度优先搜索
  6. Android中添加背景音乐的两种方法
  7. ORACLE的分布式管理
  8. VS2010 工具箱组件添加重复
  9. ES6新特性_ES6语法糖_ES5中构造函数的继承---JavaScript_ECMAScript_ES6-ES11新特性工作笔记035
  10. 简单实现下载功能--jsp,servlet
  11. 兜兜转转~~,忘不了的break!! 忘不了的continue!!!!
  12. 中日海军实力分类比较
  13. 如何在Android上关闭YouTube烦人的自动播放缩略图
  14. fio_generate_plots
  15. 亚马逊服务器一键重装系统,如何使用Amazon Alexa轻松设置智能家居设备
  16. 财管U08 公司估值 教材笔记
  17. 【mcuclub】四相五线步进电机
  18. python里randint是什么意思_Python中random.randint方法(精选)
  19. SQL Server数据库入门学习
  20. SQL优化不会?推荐4 款工具

热门文章

  1. 人工智能的突破需要颠覆图灵机吗?
  2. c++ 迭代器支持的运算
  3. php 目录限制,限定某个目录禁止解析php,限制user_agent,php相关配置
  4. 4-希尔排序C实现(递增递减的简单转换)
  5. k8s包管理器helm_kubernetes包管理神器-Helm
  6. 活动目录从入门到精通
  7. Powerdesigner数据库建模工具教程
  8. mysql-零基础安装
  9. windows下安装及配置 golang 的Web框架Beego环境
  10. 栈和队列----用栈求解汉诺塔问题