今天碰到一个算法题觉得比较有意思,研究后自己实现了出来,代码比较简单,如发现什么问题请指正.思路和代码如下: 基本思路:从左开始取str的最大子字符串,判断子字符串是否为str的后缀,如果是则返回str加子字符串剩余部分:如果不是则逐步减少子字符串长度后在进行比较./* * 给出一个字符串s,输出包含两个字符串s的最短字符串,如s为abca时,输出则为abcabca */ public class ContainTwoString { public static String MergeStri…
sed -n '/字符串1/,/字符串2/p' filename  这个命令为什么有时候打印不出来想要的东西,例如:sed -n '/root/,/adm/p'  /etc/passwd      我想/etc/passwd中包含root的行到包含adm的行,结果却是:# sed -n '/root/,/adm/p' /etc/passwdroot:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:dae…
// ConsoleApplication10.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> #include <vector> using namespace std; class Solution { public: /** * 返回git树上两点的最近分割点 * * @param matrix 接邻矩阵,表示git树,matrix[i][j] == '1' 当且仅当git树中…
// list = normalList.Except(repairList).ToList(); //差集 // list = normalList.Union(repairList).ToList(); //并集 list = normalList.Intersect(repairList).ToList(); //交集 bool result = list.All(repairList.Contains) && list.Count() == repairList.Count();…
$string = 'Lorem ipsum dolor sit amet'; $preg = '/caoyang/'; $status = preg_match($preg, $string,$matches); echo $status; var_dump($matches);die;…
/** * 从listA里删除listB里有的数据 * @param listA * @param listB * @return */ public static List<String> listrem(List<String> listA,List<String> listB){ for (Iterator<String> itA = listA.iterator(); itA.hasNext();) { String temp = itA.next(…
示例代码: <script type="text/javascript"> var str = "测试一个字符串(ehtrzes)是否包含另外一个字符串"; if (str.indexOf("(ehtrzes)") >= 0) { alert('字符串中包含(ehtrzes)字符串'); } else { alert('字符串中 不包含(ehtrzes)字符串'); } </script> indexOf用法详解: …
Jquery 选择器 详解   在线文档地址:http://tool.oschina.net/apidocs/apidoc?api=jquery 各种在线工具地址:http://www.ostools.net/ 一.基本选择器 1 $("#div1").html("hello world 1"); //根据id匹配元素(a) 2 $(".c1").html("hello world 2"); //根据Yclass匹配元素(b)…
--当charindex返回值大于0时则包含 为0不包含 select CHARINDEX('456','123456')   SQL语句使用CHARINDEX函数,来测试一个字符串中是否包含另一个字符串中的方法: 一.CHARINDEX函数介绍 1.函数功能:函数返回字符或者字符串在另一个字符串中的起始位置. 2.语法:CHARINDEX ( expression1 , expression2 [ , start_location ] ) 3.参数说明:expression1是要到expres…
转自 http://www.maomao365.com/?p=9858  摘要: 下文讲述sqlserver中最快获取一个字符串在另一个字符串中出现个数的方法分享 实验环境:sql server 2008 R2 实现思路: 1.使用replace替换字符串后 2.使用Len获取替换后的长度, 3.得出替换前和替换后的长度差 4.使用长度差除以替换字符串的长度,所得到的商即为"替换的个数". ) ) --待替换字符串 set @a ='maomao' --原字符串赋值 set @b ='…