Java RegEx One line


  • 0
    P
    public class Solution {
        public boolean isNumber(String s) {
            s = s.trim();
            String reg = "^[-+]?((\\d+)([.]\\d*)?|[.]\\d+)(e[-+]?(\\d+))?";
            return (s.matches(reg));
        }
    }
    
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.