Linked Questions

541 votes
17 answers
641k views

I want to check if a string contains only digits. I used this: var isANumber = isNaN(theValue) === false; if (isANumber){ ... } But, realized that it also allows + and -. Basically, I want to ...
patad's user avatar
  • 9,722
2 votes
0 answers
636 views

I'm wondering what regex pattern I could use to detect if every character in a string is numeric. So, here's what I'm thinking that isn't working: stringr::str_detect("311apple", "[0-9]") #> [1] ...
Evan O.'s user avatar
  • 1,573
-4 votes
1 answer
347 views

I want a Javascript regex to replace only numbers i.e. all others alphabets and special characters are allowed.
Axel's user avatar
  • 5,261
-4 votes
1 answer
151 views

I'm looking for a regex javascript expression for allowing only numbers at this format 1234. Not 1,234 or 1.234. I'm having this regex now but it does not seem to work properly /[a-z]/i
RamAlx's user avatar
  • 7,486
0 votes
3 answers
272 views

How could I do it in Node.js to recognize if a string is a valid number? Here are some examples of what I want: "22" => true "- 22" => true "-22.23" => true "22a" => false "2a2" ...
Enrique Moreno Tent's user avatar
0 votes
0 answers
90 views

I have a function to check integer format using ballerina regex. I'm using ballerina 0.990.2 and it gives result=false. How can I check integer format using regex in ballerina lang? function ...
Piraveena Paralogarajah's user avatar
1018 votes
12 answers
822k views

Consider a non-DOM scenario where you'd want to remove all non-numeric characters from a string using JavaScript/ECMAScript. Any characters that are in range 0 - 9 should be kept. var myString = '...
p.campbell's user avatar
  • 101k
219 votes
22 answers
442k views

I have a task to match floating point numbers. I have written the following regular expression for it: [-+]?[0-9]*\.?[0-9]* But, it returns an error: Invalid escape sequence (valid ones are \b \t ...
Gopal Samant's user avatar
  • 2,309
5 votes
6 answers
42k views

I'm attempting to validate a field name to match a certain format in JavaScript using Regular Expressions. I need the string inputted to resemble this: word\word\word So anything inputted can't be ...
AisRuss's user avatar
  • 279
2 votes
3 answers
5k views

I created the following Typescript extension to convert a string to Number: declare global { interface String { toNumber(): number | null; } } String.prototype.toNumber = function(this: ...
Miguel Moura's user avatar
2 votes
1 answer
4k views

I feel like this is simple but I can't get it to work... I am using Ui-Router 2.11 which includes optional parameters with regex expressions. I have this url which works '/event/{eventId:[0-9]}' ...
Matt Foxx Duncan's user avatar
0 votes
1 answer
7k views

I am trying to check if the user enters at least one number. If yes, the output = 'okey' else 'no number'. This works only for the first number, however when I enter 2, the function answers 'no number'...
mad.mix's user avatar
  • 53
0 votes
3 answers
3k views

I have a controlled number input in a React app, and when I remove all the digits right of the decimal point, the decimal point itself is removed. So when I have 1.1, and remove the rightmost 1, it ...
Tamás Sallai's user avatar
1 vote
4 answers
1k views

I am new in javascript. I have no idea of javascript and I am still learning. I want a small help. I have a label with a number. The user has to manually enter a number in a textbox. If the value ...
Anaya P's user avatar
  • 43
0 votes
2 answers
749 views

Following the Question Synchronize JTextField values by property change listener I have tried to modify the example from the answer using document listener. What I wanted to modify was to synchronize ...
user1946440's user avatar

15 30 50 per page