[GLLUG] Changing words into numbers
stew at messeduphare.co.uk
Tue Aug 14 10:09:46 UTC 2018
I'm sure other popular scripting languages would have similar
On Tue, 2018-08-14 at 10:46 +0100, John Levin via GLLUG wrote:
> Dear list,
> A problem which I think has a philosophical side as much as a
> practical one:
> What is the best way (or what are the ways) to replace numbers
> out in words with digits?
> (e.g. "the year one thousand eight hundred and seventy six" to 1776,
> "nine hundred and ninety pounds" to 999 pounds).
> One obvious solution I've thought of is to automatically generate a
> of all numbers spelled out from one to n, pair them with the
> value, then simply loop through the list and target texts
> the former with the latter. But this strikes me as very blunt and
> uneconomical. And probably impracical in that the top most number may
> very high (I don't know what the highest number in the texts I have
> though I have seen 'thirty-eight million nine hundred and ninety-
> Could there be a regex solution that generates the number from the
> What other approaches could I take?
> Thanks in advance,
> John Levin
More information about the GLLUG