Java实现计算字符串表达式

一个java 的计算字符串表达式的组件

官方站点:http://www.japisoft.com/formula/

 

贴一下支持的操作符:

FormulaOperators :

Type
Operator
Example
Numerical operators
+ - * / : Basic operators
% : Modulo operators (not in high precision )
^ : Power operators (not in high precision )
(-1 + 50*2 ) / ( 2^4 )
Boolean operators
~, xor : operators
&&, and : And operators
||, or : Or operators
!, not : Not operators
< : less operator
> : great operator
<= : less or equal operator
>= : great or equal operator
==, equals : equal operators
!=, <> : not equal operators


!(A && (B < 10))  |  NOT ( A XOR ( B equals C ) )
A != 2 || B > 2
"string1" == "string2"
A or B
A or ( B <> C )
String operators
== : 2 strings equals
!= : 2 strings not equals
<> : 2 strings not equals
< : The first string less lexically than
the second one
> : The first string great lexically than
the second one
<= :The first string less or equals lexically than
the second one
>= : The first string great or equals lexically than
the second one
+ : Concat string
"string1" == "string2"  : false
"string1" + "a" : "string1a"
"abc" > "aaa" : true
"zyx" < "bcd" : false



List operators
+ : Concat two lists
- : Substract a list to another one
in : Test if an element is inside a list
(1,2)+(3,4) = (1,2,3,4)
(1,2) + 3 = (1,2,3)
3+(1,2)=(1,2,3)
(1,2,3,4)-(3,4)=(1,2)
(1,2,3,4)-3=(1,2,4)
2 in (1,2,3)=true
4 in (1,2,3)=false
Other operators
= : set a variable operator
[] : absolute value
² : power 2 operator
% : Percent operators
A = [ 2 - A ] * 2

10%=0.1
Conditional operators
if then
if then else
if ( A > 2 ) then "Ok"
if ( A <=2 ) THEN B=3 else B=4
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值