zoukankan
html css js c++ java
用正则表达式完成简单公式的替换计算
//
用正则表达式完成替换计算
//
检验
if
(Common.GetMatchStr(
this
.sumitem,
@"
\w+([+\-*/]\w+)*
"
).Length
!=
sumitem.Length)
return
-
1
;
string
op
=
Common.GetMatchStr(sumitem,
@"
^\w+
"
);
double
ret
=
Cvt(op);
while
(op.Length
!=
sumitem.Length )
//
{
string
oper
=
sumitem.Substring(op.Length,
1
);
sumitem
=
sumitem.Substring(op.Length
+
1
);
op
=
Common.GetMatchStr(sumitem,
@"
^\w+
"
);
double
opval
=
Cvt(op);
switch
(oper)
{
case
"
+
"
:
ret
+=
opval;
break
;
case
"
-
"
:
ret
-=
opval;
break
;
case
"
*
"
:
ret
*=
opval;
break
;
case
"
/
"
:
ret
/=
opval;
break
;
}
}
暂时不支持运算符的优先级和括号。
查看全文
相关阅读:
百度网盘下载速度慢的问题解决
问题汇总
centos 遇到Name or service not known
centos7 下 python3 和python2 同时存在但是无法使用pip3 的解决方案
pycharm2020(最简单的方法)配置远程连接服务器
pycharm2020.1.2激活
centos安装成功bart标注工具
keras遇到bert实战一(bert实现分类)
使用Array.slice(0) 实现数组浅拷贝
try/catch/finally 语句
原文地址:https://www.cnblogs.com/jetz/p/449299.html
最新文章
SpringBoot中yaml配置对象
使用java代码关闭指定端口的程序-windows
使用代码向一个普通的类注入Spring的实例
MongoDB分组汇总操作,及Spring data mongo的实现
解决iframe作为子窗口,刷新后iframe页面跳转到其它页面的问题
设置eclipse中自动添加get,set的注释为字段属性的注释
docker进入后台运行的容器
docker对数据卷进行还原操作
【转】在Eclipse里查看Java字节码
Spring3.2 Contorller单元测试参数问题: java.lang.NoSuchMethodException
热门文章
Spring 3.2 @Autowired异常:expected single matching bean but found 2
ArcGis10.1 Feature Class Properties无法编辑
ArcGis数据分类(ClassBreaksDefinition)
Arcgis10.1 Arcobject连接Oracel数据库
IE10下 FormsAuthentication.SetAuthCookie无效的问
Nginx upstream的5种权重分配方式【转】
IIS 无法显示网页问题
WPF控件收集
eclipse安装go插件
pytorch linux GPU安装
Copyright © 2011-2022 走看看