What formula can I use to check if a string is entirely digits?
As mentioned in the title, what formula can I use to check if a string is entirely digits?
Best Answer
C
CJ Wee
said
almost 6 years ago
Hi Saul,
You can use the .match formula together with a regex (regular expression).
The formula .match checks if your data pill contains a certain pattern (which can be a regex, or a string). If there is a match, the formula will evaluate to true, if not, false.
The formula will look like this: <data pill>.match?(/^[0-9]+$/).
Using this formula, if your data pill only contains digits, it will evaluate to true, and if it contains characters other than digits, it will evalute to false.
Try it out and let us know if it works.
Thanks!
Answer
CJ Wee
said
almost 6 years ago
Hi Saul,
You can use the .match formula together with a regex (regular expression).
The formula .match checks if your data pill contains a certain pattern (which can be a regex, or a string). If there is a match, the formula will evaluate to true, if not, false.
The formula will look like this: <data pill>.match?(/^[0-9]+$/).
Using this formula, if your data pill only contains digits, it will evaluate to true, and if it contains characters other than digits, it will evalute to false.
Saul Macht
What formula can I use to check if a string is entirely digits?
As mentioned in the title, what formula can I use to check if a string is entirely digits?
Hi Saul,
You can use the .match formula together with a regex (regular expression).
The formula .match checks if your data pill contains a certain pattern (which can be a regex, or a string). If there is a match, the formula will evaluate to true, if not, false.
The formula will look like this: <data pill>.match?(/^[0-9]+$/).
Using this formula, if your data pill only contains digits, it will evaluate to true, and if it contains characters other than digits, it will evalute to false.
Try it out and let us know if it works.
Thanks!
CJ Wee
Hi Saul,
You can use the .match formula together with a regex (regular expression).
The formula .match checks if your data pill contains a certain pattern (which can be a regex, or a string). If there is a match, the formula will evaluate to true, if not, false.
The formula will look like this: <data pill>.match?(/^[0-9]+$/).
Using this formula, if your data pill only contains digits, it will evaluate to true, and if it contains characters other than digits, it will evalute to false.
Try it out and let us know if it works.
Thanks!