在流中查找任意字串
来源:互联网 发布:测谎仪软件 编辑:程序博客网 时间:2024/06/15 02:30
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
开发中有时需要在流中查找某个字串,这些字串有可能是ASCII表后半部分或混杂.但是网上提供的例程效果不佳而且代码冗长.
后来自己抽个时间写了一个,代码极少,效率很高.仅供各位参考:
function ScanStream(T:Tstream;S:String):integer;
var i,j:integer;
p:Pchar;
begin
getMem(p,T.size);//分配内存
T.ReadBuffer(p^,t.Size );//读
for i:=0 to T.Size -1 do begin
for j:=1 to length(S) do
if p[i+j]<>S[j] then break;//有一个不同即退出
if j>length(S) then begin //依据
result:=i+1;
break; //完成
end;
end;
FreeMem(p);
end;
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
- 在流中查找任意字串
- 在流中查找任意字串
- 在流中查找任意字串
- 在字符串中查找最长的数字串
- 查找字符串 中字串个数
- SQL在字符串中查找字串出现第N次的位置
- 字串查找
- 查找字串
- C 在一个字串s1中查找一子串s2,若存在则返回s1中s2的个数和位置
- [百度]数组A中任意两个相邻元素大小相差1,在其中查找某个数。
- 数组A中任意两个相邻元素大小相差1,在其中查找某个数。
- 输入一维数组中任意一个数,查找它在数组中的位置
- 查找字符串中连续的最长的数字串
- 字符串中查找包含字串的次数的算法
- 用KMP算法查找字符串中字串位置
- NSIS查找文本中是否包含某个字串
- 查找两个字符串中最大相同的字串
- 转载:字串查找代码
- 《网络吸管》开发手记
- 对CSS类及id的规范化命名
- 字存为字符图片
- 利用css里expression来实现界面对象的批量控制
- MySQL常见错误问答!
- 在流中查找任意字串
- 用CSS样式表缩写给你的网站加速
- MySQL被计划转为Linux文件系统
- 深入Delphi编程.txt
- MySQL数据库应该如何对抗解密高手
- 柱状统计图表的CSS实现
- 教你如何编写高效的MySQL数据库应用
- delphi连接数据库浅谈
- 用CSS制作表头固定的表格