Sharing Regular Expression


  • 0
    D

    /**

    • @param {string} s

    • @return {boolean}
      */
      var isNumber = function(s) {

      // patternPublic = /^(?!\w*)?\s*\s*(?!\w*)?$/;

      // patternFloat = /[+-]?(((\d+)([.])?(\d*))|((\d*)([.])?(\d+)))/;

      // E = /([eE][+-]?\d+)?/;

      var pattern = /^(?!\S*)?\s*[+-]?(((\d+)([.])?(\d*))|((\d*)([.])?(\d+)))([eE][+-]?\d+)?\s*(?!\S*)?$/;

      return pattern.test(s) ;
      };

    // I'm still trapped in loop...


Log in to reply
 

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