← Back to challenges

Is it a Valid Floating Numeric Character?

JavaScriptHardregexstringslogicvalidation

Instructions

Create a regular expression to check whether the given string is a valid floating numeric character or not.

Examples

isFloatingCharacter("12.12") ➞ true

isFloatingCharacter("12.") ➞ false

isFloatingCharacter(".1") ➞ true

isFloatingCharacter("-.1") ➞ true

isFloatingCharacter("abc") ➞ false

Notes

  • All inputs are strings.
  • Think about RegExp.prototype.test().
javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Largest Gap