字符串一:1001*1003+(1005-5002)
其中1001对应数值:23.6
1003对应数值:15
1005对应数值:65
5002对应数值:652
我要结果字符串二:23.6*15+(65-652)
依次把数值替换回去。
其中1001对应数值:23.6
1003对应数值:15
1005对应数值:65
5002对应数值:652
我要结果字符串二:23.6*15+(65-652)
依次把数值替换回去。
解决方案 »
- delphi里面如何弹出文本文件
- 这是为什么呢?
- 请教高手,三次握手成功后为什么不能发送数据呢?
- 继承的Active form 为什么没有guid?
- 雪地跪求Delphi7语法手册...
- 关于报表总计的问题。。。在线急等您回答
- 哈哈,可用分又涨到1000了!所以特来大送分--请教各位如何在一个窗口的多个TDBEdit控件中同时输入多条记录同一个字段的值?
- 关于dbgrid的两个问题,请大家帮忙!!
- indexof的使用问题 Orz
- 如何把MDI里的子窗体做成没有边框(标题)?
- 我想从入库表中查找编号,日期,数量三个字段,并按日期降序排列,同时把编号相同的只取第一条.怎么实现?
- .db是什么数据库格式?谁有过传奇数据库程序的编写,可否请教下。
TToken=record
strName:string;
strValue:string;
end;const
TokenCnt = 4;
strToken:array[0..TokenCnt-1] of TToken=(
(strName:1001;strValue:'23.6'),
(strName:1003;strValue:'15'),
(strName:1005;strValue:'65'),
(strName:5002;strValue:'652')
);
strOper:set of char=['+','-','*','/','(',')'];function AStringReplace(strOld:string):string;
var
i:integer;
strValue:string;
begin
strValue:=strOld;
for i:=0 to TokenCnt-1 do
if strOld=strToken[i].strName then
strValue:=strToken[i].strValue;
Result:=strValue;
end;function MyReplace(strTemp:string):string;
var
strVar:string;
strValue:string;
i:integer;
begin
strVar:='';
strValue:='';
for i:=1 to Length(strTemp) do
begin
if (strTemp[i] in strOper) then
begin
strVar:=AStringReplace(strVar);
strValue:=strVar+strTemp[i]+MyReplace(Copy(strTemp,i+1,length(strTemp)));
break;
end else
strVar:=strVar+strTemp[i];
end;
if strValue='' then
strValue:=AStringReplace(strTemp);
Result:=strValue;
end;procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
strTemp:string;
begin
strTemp:='1001*1003+(1005-5002)'
strTemp:=MyReplace(strTemp);
Label1.Caption:=strTemp;
end;