洞察企业如何通过模块化APP集成工具高效管理多平台小程序
605
2022-10-09
65. Valid Number
Validate if a given string is numeric.
Some examples: “0” => true ” 0.1 ” => true “abc” => false “1 a” => false “2e10” => true Note: It is intended for the problem statement to be ambiguous. You should gather all requirements up front before implementing one.
Update (2015-02-10): The signature of the C++ function had been updated. If you still see your function signature accepts a const char * argument, please click the reload button to reset your code definition.
class Solution { public boolean isNumber(String s) { if(s.trim().isEmpty()){ return false; } String regex = "[-+]?(\\d+\\.?|\\.\\d+)\\d*(e[-+]?\\d+)?"; if(s.trim().matches(regex)){ return true; }else{ return false; } }}
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~