public static bool StartBy(this string thisValue, params string[] startBy)
{
foreach (string item in startBy)
{
if (thisValue.StartsWith(item))
return true;
} return false;
} public static bool StartBy(this string thisValue, string startBy, char splitSign)
{
string[] starts = startBy.Split(splitSign);
if (starts.Length > 0)
foreach (string item in starts)
{
if (thisValue.StartsWith(item))
return true;
} return false;
} public static bool IsMatch(this string thisValue, string regexPattern)
{
return Regex.IsMatch(thisValue, regexPattern);
} public static string ReplaceString(this string thisValue, string regexPattern, string replacement)
{
//Bug Fix
if (!string.IsNullOrEmpty(thisValue))
{
return Regex.Replace(thisValue, regexPattern, replacement, RegexOptions.IgnoreCase);
}
return string.Empty;
} public static bool IsIn(this string thisValue, params string[] stringCollect)
{
if (stringCollect == null || stringCollect.Length <= 0)
return false; return Array.IndexOf(stringCollect, thisValue) > -1;
} public static T IfNullThen<T>(this object thisValue, T val)
{
return thisValue == null ? val : (T) thisValue;
} public static string[] GetSubString(this string thisValue, string regexPattern)
{
string[] result = null;
MatchCollection collection = Regex.Matches(thisValue, regexPattern, RegexOptions.IgnoreCase);
if (collection.Count > 0)
{
result = new string[collection.Count];
for (int i = 0; i < collection.Count; i++)
{
result[i] = collection[i].Value;
}
} return result;
} public static string GetHashCode(this string thisValue, int leftLength)
{
string hashCode = Newegg.BigData.Framework.Common.ShareFunctions.GetHashCode(thisValue);
return hashCode.Length >= 4 ? hashCode.Substring(0, leftLength) : hashCode;
} public static string GetRowKeyHashCode(this string thisValue)
{
return thisValue.GetHashCode(4);
}

  

一些有用的UtilityExtend小方法的更多相关文章

  1. android 小方法

    小方法 1.获取屏幕分辨率: public class BaseTools { public static int getWindowWidth(Context context) { // 获取屏幕分 ...

  2. jQuery提供的小方法

    jQuery提供的小方法: 1.选择器 + 事件 + 函数 = 复杂的交互 2.循环处理与选择器匹配的各个元素:each() $("#").each(function(){     ...

  3. WinForms C#:html编辑器工程源码,含直接写WebBrowser的文件流、IPersistStreamInit接口的声明和一些相关的小方法

    原文:WinForms C#:html编辑器工程源码,含直接写WebBrowser的文件流.IPersistStreamInit接口的声明和一些相关的小方法 首先多谢朋友们的捧场: 今天给大家带来一个 ...

  4. SharePoint 查找字段内部名称的小方法

    今天逛博客园,偶然看到了下面的文章,介绍不用工具查看SharePoint字段内部名称,也介绍下自己的小方法. http://www.cnblogs.com/sunjunlin/archive/2012 ...

  5. wdatepicker控件de使用小方法汇总

    在总结wdatepicker控件的使用前,先插播一条吧,下午刚心血来潮百度的一条 问?C#中Int16.Int32.Int64.之间的区别,:::嘿嘿其实百度知道就有,但还是写上吧! Int16 表示 ...

  6. 提高django model效率的几个小方法

    django的model效率不是很高,特别是在做大量的数据库操作的时候,如果你只用django来开企业站或者外包项目的话,那可以小跳过下,而你恰巧是效率狂或者说是对程序的效率要求比较高的话,那就要注意 ...

  7. python - 常用的小方法

    常用的小方法: bin() oct() hex() chr() ord() dir() id() len() int() str() type() help() range(10)   /  rang ...

  8. (转)java中查找List的快捷小方法

    相信java开发的程序员,经常会遍历list里的数据,来查找想要的数据.之后选出来在做处理,我这有个小方法在大量数据的情况下能更快捷,当然这方法只对菜鸟有点用,对老鸟来说也许有更好的方法,请指点 遍历 ...

  9. C#中DEV控件,XtraTabPage得小方法

    DEV控件设计窗体程序,XtraTabPage用到的小方法,欢迎大家评论,分享技术! //DEV中的选项卡 private bool TabCtlPageExist(string pageName) ...

随机推荐

  1. Md5加密方法

    package com.atguigu.surveypark.util; import java.security.MessageDigest; /** * 数据 */ public class Da ...

  2. mybatis 返回null 及 参数说明

    'org.mybatis:mybatis:3.2.8' (会与 'org.mybatis:mybatis:3.1.1',com.mybank.tools.dialect.PaginationInter ...

  3. .NET 4.6中的性能改进

    .NET 4.6中带来了一些与性能改进相关的CLR特性,这些特性中有一部分将会自动生效,而另外一些特性,例如SIMD与异步本地存储(Async Local Storage)则需要对编写应用的方式进行某 ...

  4. hibernateTemplate.find或hibernateTemplate.save()执行操作没有反应,但是有sql语句

    今天使用ssh框架搭建的项目,进行查询和保存操作,使用的是 public Collection<T> getAllEntry() { return this.hibernateTempla ...

  5. 使用 ContentProviderOperation 来提升性能

    ContentProviders  是android 系统核心组件之一,ContentProviders 封装了数据的访问接口,其底层数据一般都是保存在数据库中或者保存在云端. 有时候你需要更新多行数 ...

  6. 【转】开启Apache mod_rewrite模块完全解答

    启用mod_rewrite模块在conf目录的httpd.conf文件中找到LoadModule rewrite_module modules/mod_rewrite.so将这一行前面的#去掉.2.在 ...

  7. TP收集一些可以用的资源

    http://www.thinkphp.cn/code/2184.html    UI http://www.thinkphp.cn/code/2158.html   报名 http://www.th ...

  8. 文件上传限制大小 dotnet/C#

    private void Button1_Click(object sender, System.EventArgs e) { if (File1.PostedFile != null) { //上传 ...

  9. ch5 MySQL 备份与恢复

    第 5 章 MySQL 备份与恢复 前言 数据库的备份与恢复一直都是 DBA 工作中最为重要的部分之一,也是基本工作之一.任何正式环境的数据库都必须有完整的备份计划和恢复测试,本章内容将主要介绍 My ...

  10. Java IO 之 FileInputStream & FileOutputStream源码分析

    Writer      :BYSocket(泥沙砖瓦浆木匠) 微         博:BYSocket 豆         瓣:BYSocket FaceBook:BYSocket Twitter   ...