本文整理自网络,侵删。
function GetBefore(substr, str:string):string;{?Drkb v.3(2007): www.drkb.ru, ?Vit (Vitaly Nevzorov) - nevzorov@yahoo.com}beginif pos(substr,str)>0 then result:=copy(str,1,pos(substr,str)-1)else result:='';end;
function GetAfter(substr, str:string):string;{?Drkb v.3(2007): www.drkb.ru, ?Vit (Vitaly Nevzorov) - nevzorov@yahoo.com}beginif pos(substr,str)>0 then result:=copy(str,pos(substr,str)+length(substr),length(str))else result:='';end;
演示:
1) GetBefore('-', 'Total-2.00$') // 结果 "Total"
2) GetAfter('-', 'Total-2.00$') // 结果 "2.00$"
3) GetBefore('$',GetAfter('-', 'Total-2.00$ (общая сумма)') // 结果 "2.00"
相关阅读 >>
Delphi 使用google translate实现tts
Delphi xe7开发的获取网页中字符串的编码是否是utf8
更多相关阅读请进入《Delphi》频道 >>