115,字符串替代
2015-12-20 10:18
225 查看
#import <Foundation/Foundation.h>
int main(int argc,
const char * argv[]) {
/*
OccurrencesOfString:被替换者,
withString:替换者
*/
NSString *str =
@"http:$$www.baidu.com$content$1012.html";
NSString *newStr = [str
stringByReplacingOccurrencesOfString:@"$"
withString:@"/"];
NSLog(@"newStr = |%@|",newStr);
/*
首尾替换
*/
NSString *str1 =
@" http://www.baidu.com/content/1012.html ";
NSCharacterSet *set = [NSCharacterSet
whitespaceCharacterSet];
NSString *newStr1 = [str1
stringByTrimmingCharactersInSet:set];
NSLog(@"newStr1 = |%@|",newStr1);
return 0;
}
//2015-12-20 10:17:17.734 10,字符串替换[1143:119825] newStr = |http://www.baidu.com/content/1012.html|
//2015-12-20 10:17:17.735 10,字符串替换[1143:119825] newStr1 = |http://www.baidu.com/content/1012.html|
//Program ended with exit code: 0
int main(int argc,
const char * argv[]) {
/*
OccurrencesOfString:被替换者,
withString:替换者
*/
NSString *str =
@"http:$$www.baidu.com$content$1012.html";
NSString *newStr = [str
stringByReplacingOccurrencesOfString:@"$"
withString:@"/"];
NSLog(@"newStr = |%@|",newStr);
/*
首尾替换
*/
NSString *str1 =
@" http://www.baidu.com/content/1012.html ";
NSCharacterSet *set = [NSCharacterSet
whitespaceCharacterSet];
NSString *newStr1 = [str1
stringByTrimmingCharactersInSet:set];
NSLog(@"newStr1 = |%@|",newStr1);
return 0;
}
//2015-12-20 10:17:17.734 10,字符串替换[1143:119825] newStr = |http://www.baidu.com/content/1012.html|
//2015-12-20 10:17:17.735 10,字符串替换[1143:119825] newStr1 = |http://www.baidu.com/content/1012.html|
//Program ended with exit code: 0
相关文章推荐
- 堆与栈 内存分配
- poj2421
- DragonBoard 410c高速扩展口详解
- 【Web】XML与HTML的区别与联系
- .Net程序员学习Linux最简单的方法(转载)
- 解决win8/8.1系统不兼容Visual C++6.0的问题
- Bootstrap-栅格布局实例
- sql
- 1032. Sharing (25)
- Daily Scrumming* 2015.12.19(Day 11)
- 深入分析JavaWeb Item28 -- 使用JDBC对数据库进行CRUD
- Android TextUtils的常用方法
- Java连接ftp服务器实例代码
- 防火墙查看、关闭与开启命令
- eclipse里面运行tomcat显示无法显示页面
- EHCache分布式缓存集群环境配置
- org.hibernate.InvalidMappingException: Could not parse mapping document from resource 处理办法
- _tkinter.TclError: no display name and no $DISPLAY environment variable
- 修改GitHub上项目语言显示
- VB.NET中的类和模块