比如:有一个字符窜叫 String "我的日记本 我的姓名 张三 我的邮件 [email protected]"我怎么把 我的姓名 和我的邮件 之间的 张三 还有我的邮件后的 [email protected] 提起出来并把 张三 [email protected]插到数据库里的表table中tabke 的字端如 email name 两个字段
解决方案 »
- 各位请帮帮看看这个内存泄露问题吧!!!
- 用api函数实现,bmp转jpg?以下的一种就可以(最好delphi版)
- 发布BDE程序,需要哪些文件
- 在listview中如何让选中checkbox时候同时该行也处于选中状态?
- 提示class TRx SpeedButton没有找到?
- 多媒体编译出错问题。
- 在开发MDI程序时,如何让子窗体显示在主窗体的一个TPanel控件里呢?
- 能否采用hook实时获得用户在我的电脑或资源管理器中选取的文件及路径?
- 很简单!高分相送,关于COM+
- 把string类型转为char如何转假设string类型的长度为1
- 如何取得DateTimePicker所显示日期对应本周从周一到周日的日期?
- 各位大哥大姐你们好,小第急需关于RAVE的资料,请各位帮帮忙为我提供点资料吧
for i:=0 to Length(AStr) do
AStr[i]
..............
函数需要引用的unit自己去看看,这里就不写出来了...(*
#==========================================================
#功能: 返回两个字符串之间的字串
#参数: cStringStr 要截取的字符串
# StartStr 起始的字符串
# EndStr 截止的字符串
#返回: 字符型 截取后的字符串
#==========================================================
*)
function SubStr(cStringStr, StartStr, EndStr: string): string;
var
iStart, iEnd: longint;begin
try
iStart := pos(StartStr, cStringStr); //返回指明字串StartStr在字串cStringStr中的iStartPosz之后的位置
if iStart = 0 then
begin
SubStr := '';
exit;
end; //返回指明字串EndStr在字串cStringStr中的位置 iEnd := pos(EndStr, cStringStr); if iEnd = iStart then
begin
SubStr := '';
exit;
end; //截取字串
if iEnd = 0 then
begin
SubStr := '';
exit;
end
else
SubStr := MidBStr(cStringStr, iStart + length(StartStr), iEnd - iStart - length(StartStr)); finally end; //try
end;
得到:
“我的日记本
我的姓名=张三
我的邮件[email protected]”第二步,利用Strings的Values属性读取值~~
Strings.Values['我的姓名']
Strings.Values['我的邮件']参考代码如下~~
var
S: string;
begin
S := '我的日记本 我的姓名 张三 我的邮件 [email protected]';
S := StringReplace(S, ' 我的姓名 ', #13#10'我的姓名=', []);
S := StringReplace(S, ' 我的邮件 ', #13#10'我的邮件=', []);
with TStringList.Create do try
Text := S;
Query1.SQL.Text := Format('insert table(email, name)values(%s,%s)',
[QuotedStr(Values['我的邮件']), QuotedStr(Values['我的姓名'])]);
try
Query1.ExecSQL;
except
{ TODO : 异常处理 }
end;
finally
Free;
end;
end;