JavaScript How to test input values using regex? angular test input values

This regular expression should work for you:

/^\d+(-\d+)?(,\d+(-\d+)?)*$/

Explanation:

  • ^ means to start at the beginning of the string, to reject strings with extra stuff at the beginning
  • \d+(-\d+)? accepts a number optionally followed by a hyphen and another number:
    • \d+ means one or more digits
    • -\d+ means hyphen plus one or more digits
    • (...)? means the pattern inside the parentheses is optional
  • (,...)* accepts 0 or more instances of comma followed by the same pattern as above
  • $ says to match until the end of the string, to reject strings with extra stuff at the end
Answer:1

i created a crypto object as follows: var crypto = { encrypt: function(s) { } }; crypto.encrypt("cat"); I would get the following error Uncaught TypeError: crypto.encrypt is ...

i created a crypto object as follows: var crypto = { encrypt: function(s) { } }; crypto.encrypt("cat"); I would get the following error Uncaught TypeError: crypto.encrypt is ...

I try to run my test.js file below with the command: DEBUG=nightmare node --harmony test.js and taking output: nightmare queueing action "goto" for http://google.com +0ms nightmare queueing ...

I try to run my test.js file below with the command: DEBUG=nightmare node --harmony test.js and taking output: nightmare queueing action "goto" for http://google.com +0ms nightmare queueing ...

I want to take every element of from the API and show it in different classes. I am getting the result in my Console but not on the page. Please Help me out. Thanks you in Advance:) . I have used ...

I want to take every element of from the API and show it in different classes. I am getting the result in my Console but not on the page. Please Help me out. Thanks you in Advance:) . I have used ...

I am trying to manipulate some float values inside of a string by a certain amount. To do so I have the following: var string = '<path d="M219.6,-71.4C249,19.1,212.7,130.9,135.7,186.8C58.8,242....

I am trying to manipulate some float values inside of a string by a certain amount. To do so I have the following: var string = '<path d="M219.6,-71.4C249,19.1,212.7,130.9,135.7,186.8C58.8,242....