Article Preview
Buy Now
FEATURE
Numbers Please! (Part 4)
A numbers-only field
Issue: 17.5 (September/October 2019)
Author: Markus Winter
Author Bio: Markus is a Molecular Biologist who taught himself REALbasic programming in 2003 to let the computer deal with some exceedingly tedious lab tasks. Some call it lazy, he thinks it smart. He still thinks of himself as an advanced beginner at best.
Article Description: No description available.
Article Length (in bytes): 35,956
Starting Page Number: 12
Article Number: 175002
Related Link(s): None
Excerpt of article text...
Last time we delineated our RegEx pattern by capturing the over-arching structure of numbers as a RegEx pattern in pseudo RegEx:
NaN | [+-]? ( INF | ? | ( (int | dec | int dec) prec? )? exp? )
This time we will start implementing the RegEx for
int
,dec
,prec
, andexp
that potentially form part of a "common number".But before we do that, we need to deal with some potential problems, specifically those caused by grouping separators and decimal separators.
While we mentioned last time that the current international standard is to use a comma or dot as the decimal separator, and a thin space as a grouping separator, in reality different countries still use different grouping and decimal separators. So in the U.S. or Britain one would usually write 15,234.56, but in Germany or France it could be written as 15 234,56 or 15.234,56. But there is far more variety than that (for example an underbar as in maritime
21_450
, and don't get me started on what some countries get up to), and the only sensible way of dealing with it is to use whatever the user set up as the locale setting. That way the user can modify that setting to suit his or her personal preference.
...End of Excerpt. Please purchase the magazine to read the full article.