swift 批量 取出中间文本
func stringmid_pl (wholestring:String,front:String,behind:String,inout return_string:String,getheroid:Bool)
{
//数组参数inout
// var whole_tmp:String = wholestring
if wholestring.isEmpty
{
// return(return_string) //wholestring 不能为nil
}else {
var whole:NSString=wholestring
var whole_tmp = whole
let frontindex = whole.rangeOfString(front)
if frontindex.length > 0
{
whole = whole.substringFromIndex(frontindex.location + frontindex.length)
let behindindex = whole.rangeOfString(behind)
if behindindex.length > 0
{
whole = whole.substringToIndex(behindindex.location)
return_string = return_string + (whole as String) + ","
// whole_tmp = whole_tmp.stringByReplacingOccurrencesOfString(front, withString: "", options: NSStringCompareOptions.LiteralSearch, range: frontindex)
//
// whole_tmp = whole_tmp.stringByReplacingOccurrencesOfString(behind, withString: "", options: NSStringCompareOptions.LiteralSearch, range: whole_tmp.rangeOfString(behind))
whole_tmp = whole_tmp.stringByReplacingOccurrencesOfString(front + (whole as String) + behind, withString: "")
if getheroid == true
{
whole_tmp = whole_tmp.stringByReplacingOccurrencesOfString(front + (whole as String), withString: "")
}
stringmid_pl(whole_tmp as String, front: front, behind: behind, return_string: &return_string,getheroid:getheroid)
// return(whole as String)
} else {
// return(return_string)
} //没有找到behind在wholestring
} else {
//return(return_string)
} // 没有找到front 在wholestring
}
}
swift 批量 取出中间文本的更多相关文章
- 如何在Word中批量选中特定文本
如何在Word中批量选中特定文本 举个例子,我们对如下文本进行操作,将文本中所有的“1111111”标红,所有的“2222222”标绿,所有的“3333333”标蓝 在Word中找到“查找”下的“高级 ...
- swift 取出中间文本
func stringmid (wholestring:String,front:String,behind:String)->String { if wholestring.isEmpty ...
- linux下批量查找/替换文本内容
一般在本地电脑上批量替换文本有许多工具可以做到,比如sublime text ,但大多服务器上都是无图形界面的,为此收集了几条针对linux命令行 实现批量替换文本内容的命令: 1.批量查找某个目下文 ...
- Swift - 发送消息(文本,图片,文件等)给微信好友或分享到朋友圈
通过调用微信提供的API接口,我们可以很方便的在应用中发送消息给微信好友,或者分享到朋友圈.在微信开发平台(https://open.weixin.qq.com)里,提供了详细的说明文档和样例.但由于 ...
- zencart批量插入TEXT文本属性attributes
有时候上传的产品与多级分类比较多,在后台添加文本属性如Name,Number等需要顾客自定义的内容就比较费神了.现在只需将以下代码保存为insert_attributes.php,变量$options ...
- 批量查询PDF文本并导出结果的小工具
效果: 批量查询指定关键字 & 指定目录下PDF文件中的文本,并导出文件路径和关键字所在文本行. 下载: 链接: https://pan.baidu.com/s/1sK2OMMgGX26l7P ...
- Swift中的富文本注释格式
Apple当前启用了Markup语法形式的富文本注释格式,并且为此列出了官方文档,可以参考此链接:https://developer.apple.com/library/ios/documentati ...
- iOS(Swift) TextField限制输入文本的长度(不是字数)
最近做项目有一个特殊需求,就是需要限制一个TextField的输入文本的长度在一定范围内(注意,不是字数),上网查了一圈没有找到类似文章,这里把我的方法写进来,mark一下: 1.对TextField ...
- Swift语言 代码添加文本输入框 和 占位文本
//懒加载文本输入框 private lazy var textView: UITextView = { let textView = UITextView() textView.font = UIF ...
随机推荐
- Android 开发错误信息001
Error:Execution failed for task ':app:dexDebug'. > com.android.ide.common.process.ProcessExceptio ...
- hdu 4348 To the moon
题意:n个数 m次操作 操作分别为 C l r d: 把区间[l, r] 加 d Q l r : 查询区间[l, r]的和 H l r t: 查询时间t的时候[l, r]的和 B t: 回到时间t 思 ...
- Notepad++配置Python开发环境
1. 安装Python 1 下载 我选择了32位的2.7版本.https://www.python.org/ftp/python/2.7.8/python-2.7.8.msi 2. 安装 安装的时候可 ...
- ajax中返回json数据有"
1.将“转义为\" string table=sb.ToString(); table.Replace("\"","\\\"");
- SNMP-配置文件详解
当下的 SNMP 服务器通常用来被诸如 Nagios.Cacti.Zabbix 等监控软件收集数据,SNMP 的很多高级特性用的不是特别频繁.因而只需对 SNMP 进行一些简单.基础的配置以满足各种监 ...
- Downloader调用WCF服务返回文件
Generator using System; using System.Collections.Generic; using System.IO; namespace Downloader { pu ...
- pt-fifo-split使用
percona-toolkit系列-pt-find http://blog.itpub.net/23249684/viewspace-1354308/ 在<mysql插入/更新数据>这篇文 ...
- linux, configure --prefix=/有什么用
作用就是指定安装路径不指定prefix,则可执行文件默认放在/usr /local/bin,库文件默认放在/usr/local/lib,配置文件默认放在/usr/local/etc.其它的资源文件放在 ...
- server application error应用错误
本地使用IIS测试ASP脚本网页,结果发现提示[Server Application Error The server has encountered an error while loading a ...
- Hibernate getCurrentSession()和openSession()的区别
通过getCurrentSession()创建的Session会绑定到当前线程上:openSession()不会. 通过getCurrentSession()获取Session,首先是从当前上下文中寻 ...