zoukankan
html css js c++ java
StringHelper字符串辅助类
using System; using System.Collections.Generic; using System.Text; using System.Globalization; using System.Text.RegularExpressions; namespace Framework { /// <summary> /// 字符串辅助类 /// </summary> public static class StringHelper { /// <summary> /// 截取字符串的后部分 /// </summary> /// <param name="source">原字符串</param> /// <param name="value">拆分字符串</param> /// <returns>截取后的字符串</returns> public static string SubstringAfter(this string source, string value) { if (string.IsNullOrEmpty(value)) { return source; } CompareInfo compareInfo = CultureInfo.InvariantCulture.CompareInfo; int index = compareInfo.IndexOf(source, value, CompareOptions.Ordinal); if (index < 0) { return string.Empty; } return source.Substring(index + value.Length); } /// <summary> /// 截取字符串的前部分 /// </summary> /// <param name="source">原字符串</param> /// <param name="value">拆分字符串</param> /// <returns>截取后的字符串</returns> public static string SubstringBefore(this string source, string value) { if (string.IsNullOrEmpty(value)) { return value; } CompareInfo compareInfo = CultureInfo.InvariantCulture.CompareInfo; int index = compareInfo.IndexOf(source, value, CompareOptions.Ordinal); if (index < 0) { return string.Empty; } return source.Substring(0, index); } /// <summary> /// 追加字符串,用分隔符分隔,默认分隔符为“,” /// </summary> /// <param name="sb">StringBulider对象</param> /// <param name="append">要追加的字符串</param> /// <param name="split">分隔符</param> public static void AppendString(this StringBuilder sb, string append, string split = ",") { if (sb.Length == 0) { sb.Append(append); return; } sb.Append(split); sb.Append(append); } /// <summary> /// 替换所有HTML标签为空 /// </summary> /// <param name="input">The string whose values should be replaced.</param> /// <returns>A string.</returns> public static string RemoveHtml(this string input) { var stripTags = new Regex("</?[a-z][^<>]*>", RegexOptions.IgnoreCase); return stripTags.Replace(input, string.Empty); } } }
查看全文
相关阅读:
form表单介绍
if条件语句
表格.html
列表.html
CSS Js链接HTML文件
DQL
mysql介绍
第一次接触mysql
逻辑运算、作用域问题、DOM
Js数据类型具体分析
原文地址:https://www.cnblogs.com/zhangqs008/p/2341091.html
最新文章
python学习Day13 函数的嵌套定义、global、nonlocal关键字、闭包及闭包的运用场景、装饰器
python学习Day12 函数的默认值、三元表达式、函数对象(函数名)的应用场景、名称空间与作用域
python学习Day11 函数的参数列表
读excel数据xlrd
Python 文件I/O
python with as的用法
python | 读文件编码问题 | UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 34: illegal mu
爬虫利器beautifulsoup4
封装与调用
正则表达式
热门文章
解决 warning I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
解决递归栈溢出
ASCII Unicode UTF-8 之间的关系
window 10 + python3.6 +numpy+ tensorflow + pycharm
整理 读过感觉不错的深度学习博客(更新中)
函数
json
数组
JS介绍
for循环基础
Copyright © 2011-2022 走看看