C经常用到的几个截取字符串_第1页
C经常用到的几个截取字符串_第2页
C经常用到的几个截取字符串_第3页
C经常用到的几个截取字符串_第4页
C经常用到的几个截取字符串_第5页
免费预览已结束,剩余2页可下载查看

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、C磔常用到的几个截取字符串C#几个经常用到的字符串的截取string str="123abc456"int i=3;1 取字符串的前i 个字符str=str.Substring(0,i); / or str=str.Remove(i,str.Length-i);2 去掉字符串的前i 个字符:str=str.Remove(0,i); / or str=str.Substring(i);3 从右边开始取i 个字符:str=str.Substring(str.Length-i); / or str=str.Remove(0,str.Length-i);4 从右边开

2、始去掉i 个字符:str=str.Substring(0,str.Length-i); / or str=str.Remove(str.Length-i,i);5 判断字符串中是否有"abc" 有则去掉之using System.Text.RegularExpressions;string str = "123abc456"string a="abc"Regex r = new Regex(a);Match m = r.Match(str);if (m.Success)/ 下面两个取一种

3、即可。str=str.Replace(a,"");Response.Write(str);string str1,str2;str1=str.Substring(0,m.Index);str2=str.Substring(m.Index+a.Length,str.Length-a.Length-m.Index);Response.Write(str1+str2);6 如果字符串中有"abc" 则替换成 "ABC"str=str.Replace("abc&quot

4、;,"ABC");*string str="adcdef" int indexStartstr.IndexOf("d");int endIndex =str.IndexOf("e");string toStr = str.SubString(indexStart,endIndex-indexStart);c#取字符串最后一个字符的问题str1.Substring(str1.LastIndexOf(",")+1);C#

5、 截取字符串最后一个字符k = k.Substring(k.Length-1, 1);<table width="1000" height="250" border="0"> <tr><td align="center" colspan="5"> <font size="+3" &am

6、p;gt;<strong> 请假 条</strong></font><hrcolor="#000000"width="500"><hrcolor="#000000"width="500"></td></tr><tr><

7、td align="right"> 单 位 : </td><td><inputtype="text"id="TxtDwName"class="textInput2"/></td><td><inputtype="text"id="Txt

8、TopYear" /> 年 <inputtype="text"id="TxtTopMon"/>月<inputtype="text" id="TxtTopDay" /> 日</td><td align="right"> 编 号 :</td>&

9、lt;td><inputtype="text"id="TxtNumber"class="textInput2"/></td></tr><tr><td align="center" colspan="5"><table width="1

10、00%" height="100%"border="1" bordercolor="#000000" ><tr ><td width="96">请假人</td><td width="250"><input type="text&quot

11、;id="txtName" /></td><td width="129"> 部门 </td><td width="439"><input type="text"id="txtbmName"class="textInput3"/>&

12、amp;lt;/td><td width="46" > 备 注</td></tr><tr><td> 休假时间 </td><td colspan="3"><inputtype="text"id="txtXjYer"/>年

13、<inputtype="text"id="txtXjMon"/>月<inputtype="text"id="txtXjDay"/>日<inputtype="text"id="saw" /> 午 <input type="text"id=&qu

14、ot;txtXjHour" /> 时至 <input type="text"id="txtNetMon" /> 月 <input type="text"id="txtNextDay" /> 日 <input type="text"id="xaw" /> 午 &

15、lt;input type="text"id="txtNexthour" /> 时共 <input type="text"id="txtDays" /> 天(工日) <input type="text"id="txthours" />时</td><td rowspan=&

16、amp;quot;4">dfsdfsd</td></tr><tr><td> 休 假 事 由 </td><tdcolspan="3"><inputtype="text"id="txtxjWhy"class="textInput4"/&g

17、t;</td></tr><tr><td> 销假时间 </td><td><input type="text" id="txtxjYear"/> 年 <input type="text" id="txtxjMony"/> 月 &

18、lt;input type="text" id="txtxjDay" />日截止 </td><td> 销假签名 </td><td><input type="text" id="txtxjName"class="textInput3" /></td></tr><tr><td> 部门负责意见 </td><td><input type="text" id="txtbmfzYj"class="textInput3" />&l

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论