• 0 Posts
  • 17 Comments
Joined 1 month ago
cake
Cake day: June 23rd, 2024

help-circle





  • You are right, “elf” is a stretch, it does not make sense to parse it as a number. But in some languages, the string “15 240,5” is just how a number is written (yes, that’s a U+2009 THIN SPACE, you can’t stop me from using it as a thousand separator in German). Obviously, despite having a , on their numpads, German programmers still expect computers to parse numbers with decimal dots and interpret commas as list values.


  • So the only valid digits are arabic numbers but arabic script numbers are not a valid digit?

    Some people writing Regex implementations have that opinion. I’ve refrained from saying mine.

    If we want programming to be inclusive then doesn’t that make sense to also include the arabic script number?

    Maybe. IMO, number tests should be chosen/implemented based on the project’s requirements. If you want to include every Unicode character or string pattern anyone’s ever used to convey a numeric value, that would be a long and growing list. Arguably, it’s impossible: the word “elf” means a number if interpreted as German for “eleven” but not if interpreted as English for 🧝.



  • If you think is-number can be replaced with a one-liner, you don’t have the enterprise code mindset. What if the world gets more inclusive and MMXXIV, ½ and ⠼⠁ become recognized as numbers? 𒐍𓆾 were numbers in the past but what if people start assigning numeric value to other characters? Are 🖐🔟💯🆢🂵🀌🁅 numbers of the future???
    /s

    I’m not even all kidding, Regex implementations are split on whether “٣” matches \d.