Chinaunix首页 | 论坛 | 博客
  • 博客访问: 582436
  • 博文数量: 109
  • 博客积分: 1463
  • 博客等级: 上尉
  • 技术积分: 859
  • 用 户 组: 普通用户
  • 注册时间: 2011-07-22 13:21
个人简介

希望和广大热爱技术的童鞋一起交流,成长。

文章分类

全部博文(109)

文章存档

2017年(1)

2016年(2)

2015年(18)

2014年(1)

2013年(9)

2012年(15)

2011年(63)

分类: Windows平台

2015-04-15 16:36:04

CString str = "\n\t a";

str.TrimLeft();

str为“a”;

如果没有参数,从左删除字符(\n\t空格等),至到遇到一个非此类字符.

当然你也可以指定删除那些字符.

如果指定的参数是字符串,那么遇上其中的一个字符就删除.

CString str = "abbcadbabcadb ";

str.TrimLeft("ab");

结果"cadbabcadb "  


MSDN

CString strBefore;CString strAfter; strBefore = "Hockey is Best!!!!"; strAfter = strBefore; str.TrimRight('!'); printf("Before: \"%s\"\n", (LPCTSTR) strBefore); printf("After : \"%s\"\n\n", (LPCTSTR) strAfter); strBefore = "Hockey is Best?!?!?!?!"; strAfter = strBefore; str.TrimRight("?!"); printf("Before: \"%s\"\n", (LPCTSTR) strBefore); printf("After : \"%s\"\n\n", (LPCTSTR) strAfter);

In the first example above, the string reading, "Hockey is Best!!!!" becomes "Hockey is Best".

In the second example above, the string reading, , "Hockey is Best?!?!?!?!" becomes "Hockey is Best".

阅读(2366) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~