package leetcode;

/**
 * https://leetcode.com/problems/valid-number/
 */
public class Problem65 {
    public boolean isNumber(String s) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem65 prob = new Problem65();
        System.out.println(prob.isNumber("0")); // true
        System.out.println(prob.isNumber(" 0.1")); // true
        System.out.println(prob.isNumber("abc")); // false
        System.out.println(prob.isNumber("1 a")); // false
        System.out.println(prob.isNumber("2e10")); // true
    }
}

@@ -144,158 +144,632 @@
     
-// TODO
+return s.matches(%22%5C%5Cs*(?:-%7C%5C%5C+)?(%5C%5Cd+%7C(?:%5C%5Cd+%5C%5C.%5C%5Cd*)%7C(?:%5C%5Cd*%5C%5C.%5C%5Cd+))(e(?:-%7C%5C%5C+)?%5C%5Cd+)?%5C%5Cs*%22);
 %0A    
+%7D%0A%0A
     
-return false;%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem65 prob = new Problem65();%0A        System.out.println
+private static void test(boolean actual, boolean expected) %7B%0A        if (actual != expected) %7B%0A            throw new RuntimeException(%22Wrong!%22);%0A        %7D%0A    %7D%0A%0A    public static void main(String%5B%5D args) %7B%0A        Problem65 prob = new Problem65();%0A        test(prob.isNumber(%220%22), true); // true%0A        test(prob.isNumber(%22123.45%22), true); // true%0A        test(prob.isNumber(%22 0.1%22), true); // true%0A        test(prob.isNumber(%22abc%22), false); // false%0A        test(prob.isNumber(%221 a%22), false); // false%0A        test
 (pro
@@ -780,19 +780,28 @@
 Number(%22
-0%22)
+2e10%22), true
 ); // tr
@@ -811,34 +811,73 @@
         
-System.out.println
+test(prob.isNumber(%221.2e10%22), true); // true%0A        test
 (prob.is
@@ -884,22 +884,31 @@
 Number(%22
- 0.1%22)
+1.2e-10%22), true
 ); // tr
@@ -922,166 +922,673 @@
     
-System.out.println(prob.isNumber(%22abc%22)); // false%0A        System.out.println(prob.isNumber(%221 a%22)); // false%0A        System.out.println(prob.isNumber(%222e10%22)
+test(prob.isNumber(%22.1%22), true); // true%0A        test(prob.isNumber(%22%22), false); // false%0A        test(prob.isNumber(%22e9%22), false); // false%0A        test(prob.isNumber(%221.21.2%22), false); // false%0A        test(prob.isNumber(%221.2e1.2%22), false); // false%0A        test(prob.isNumber(%223.%22), true); // true%0A        test(prob.isNumber(%22.%22), false); // false%0A        test(prob.isNumber(%22-12.%22), true); // true%0A        test(prob.isNumber(%22-.234%22), true); // true%0A        test(prob.isNumber(%22-2.2e3.4%22), false); // false%0A        test(prob.isNumber(%22-2.2e-3.4%22), false); // false%0A        test(prob.isNumber(%22+.8%22), true); // true%0A        test(prob.isNumber(%22 005047e+6%22), true
 ); /

Update problem 65