function GetBefore(substr, str:string):string; {©Drkb v.3(2007): www.drkb.ru, ®Vit (Vitaly Nevzorov) - [email protected]} begin if 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) - [email protected]} begin if 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 根据特殊符号字符获取字符串前或后的字符
猜你喜欢
转载自www.cnblogs.com/jijm123/p/11413821.html
今日推荐
周排行