String input="Double result = Math.pow( 3.0,16.0);"
+"DOuble results = Math.pow(2,result);"
+"DOUble reslutMap= Math.pow(2.0, 38.0);"
+"DOUBle results = Math.pow(2,result);"
+"DOUBLe reslutMap= Math.pow(2.0, 38.0 );"
+"DOUBLE reslutMap= Math.pow(2.0, 38.0 );"
+ "Math.pow()";请如果使用正式表达式
可以得到 下面的结果:
"result = Math.pow( 3.0,16.0);
results = Math.pow(2,result);
reslutMap= Math.pow(2.0, 38.0);
results = Math.pow(2,result);
reslutMap= Math.pow(2.0, 38.0 );
reslutMap= Math.pow(2.0, 38.0 )";请高手指点一下?谢谢!
String input = "Double result = Math.pow( 3.0,16.0);"
+ "DOuble results = Math.pow(2,result);"
+ "DOUble reslutMap= Math.pow(2.0, 38.0);"
+ "DOUBle results = Math.pow(2,result);"
+ "DOUBLe reslutMap= Math.pow(2.0, 38.0 );"
+ "DOUBLE reslutMap= Math.pow(2.0, 38.0 );" + "Math.pow()";
String regex = "\\s([^=]*\\s*=\\s*[^=]*;)";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
while (m.find()) {
System.out.println(m.group(1));
}
如
String str = "from (select * from a where name in ";
str += "(select name from names order by id) order by name)";
但是 from[大小写不确定可能会是 FROM、From、FRom、FROm、等 order by 也一样]
请问想得到 下面的结果:
"(select * from a where name in ";
"(select name from names order by id) ";
String regex = "\\s([^=]*\\s*=\\s*[^=]*;)";
==========
\\s 一个空格
[^=] 除了=外的任意字符
* 零个或多个
() 表示分组,从1开始
================
如果不懂,可以去查下正则表达式的相关资料至于你的第二个问题,也是一样的原理,
在正则表达式里,大小写不是问题,重要的是先写出那个表达式