Explode TArray
function Explode(const Separator, S: string; Limit: Integer = 0): TArray;
var
SepLen : Integer;
F, P : PChar;
ALen, Index : Integer;
begin
SetLength(Result, 0);
if (S = '') or (Limit < 0) then
Exit;
if Separator = '' then
begin
SetLength(Result, 1);
Result[0] := S;
Exit;
end;
SepLen := Length(Separator);
ALen := Limit;
SetLength(Result, ALen);
Index := 0;
P := PChar(S);
while P^ <> #0 do
begin
F := P;
P := StrPos(P, PChar(Separator));
if (P = nil) or ((Limit > 0) and (Index = Limit - 1)) then
P := StrEnd(F);
if Index >= ALen then
begin
Inc(ALen, 5); //
SetLength(Result, ALen);
end;
SetString(Result[Index], F, P - F);
Inc(Index);
if P^ <> #0 then
Inc(P, SepLen);
end;
if Index < ALen then
SetLength(Result, Index); //
end;
type
TArray = array of string;
.....
var
arr: TArray;
begin
arr := explode(',', 'Mark,Michel,segment,');
end;
Explode TArray的更多相关文章
- [PHP源码阅读]explode和implode函数
explode和implode函数主要用作字符串和数组间转换的操作,比如获取一段参数后根据某个字符分割字符串,或者将一个数组的结果使用一个字符合并成一个字符串输出.在PHP中经常会用到这两个函数,因此 ...
- PHP中explode和implode的区别
字符串的连接与分割是非常重要的两个内容,通过其可以将数组按照指定的规则转换成字符串,也可以将字符串按照指定的规则进行分割,返回一个数组.其应用范围很广,如在购物网站的购物车,在线投票系统等.这两项技术 ...
- PHP explode()函数
源起:将日期格式的字符串拆分成年.月.日,用于组织关系介绍信的特定位置打印.感谢倪同学提供思路 定义和用法 explode()函数把字符串分割为数组 语法 explode(separator,stri ...
- PHP list,explode的使用
PHP list,explode的使用 <?php header("Content-type: text/html; charset=utf-8"); echo " ...
- explode,split,preg_split性能比较
explode,split,preg_split性能比较 分类: php2012-07-12 09:46 1109人阅读 评论(1) 收藏 举报 三个函数都是用来对字符串进行分割,下面分几个实验来 ...
- php中explode与split的区别介绍
php中explode与split的区别介绍 作者: 字体:[增加 减小] 类型:转载 今天在使用split时遇到一些问题.还是对函数理解不深刻,特写出来做个记 首先来看下两个方法的定义: 函数原型: ...
- php中的字符串常用函数(五) explode 妙用
// 示例 2 $data = "foo:*:1023:1000::/home/foo:/bin/sh" ; list( $user , $pass , $uid , $gid , ...
- c语言求平面上2个坐标点的直线距离、求俩坐标直线距离作为半径的圆的面积、递归、菲波那次数列、explode
#include <stdio.h> #include <math.h> #include <string.h> char explode( char * str ...
- split(),preg_split()与explode()函数分析与介
split(),preg_split()与explode()函数分析与介 发布时间:2013-06-01 18:32:45 来源:尔玉毕业设计 评论:0 点击:965 split()函数可以实 ...
随机推荐
- c语言求平面上2个坐标点的直线距离、求俩坐标直线距离作为半径的圆的面积、递归、菲波那次数列、explode
#include <stdio.h> #include <math.h> #include <string.h> char explode( char * str ...
- Android 学习第9课,java android 项目的安装与启动过程
android 安装过程: 开发工具先把.java文件转换成.class,然后转换成dx,再签名打包成apk,最后在设备上执行 adb install c:\xxx.apk android 启动过程: ...
- webpack脚手架搭建(简单版)
运行命令 安装依赖:npm install 运行项目:npm start 大致流程 npm init:新建 package.json 将需要的依赖模块加入 dependencies(生产环境) 和 d ...
- day11_API第一天
1.Eclipse常用操作 1:安装 A:解压 B:复制到指定的目录(不要有中文,和其他非法字符) 2:使用 A:打开软件的界面 B:新建一个项目(工程) C:在 ...
- TYVJ 1074 武士风度的牛
easy BFS 注意输入是反的就OK了 #include <cstdio> #include <iostream> #include <queue> using ...
- Spring将多个配置文件引入一个配置文件中
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.sp ...
- dedecms recommend 注入 exp
我看没人用python写过发过 所以我就发一下 喜欢用python的就用我这个吧 不喜欢的就用JAR那个或者PHP那个吧 #coding:GBK import re import urllib &q ...
- Sprint第一个冲刺(第九天)
一.Sprint介绍 建立云端数据库,把注册的内容保存到云端,不易丢失. 实验截图: 任务进度: 二.Sprint周期 看板: 燃尽图:
- SIFT定位算法关键步骤的说明
1. SIFT算法中一些符号的说明 $I(x,y)$表示原图像. $G(x,y,\sigma)$表示高斯滤波器,其中$G(x,y,\sigma) = \frac{1}{2\pi\sigma^2}exp ...
- spring Transaction Propagation 事务传播
spring Transaction中有一个很重要的属性:Propagation.主要用来配置当前需要执行的方法,与当前是否有transaction之间的关系. 我晓得有点儿抽象,这也是为什么我想要写 ...