<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta content="text/html;charset=UTF-8" http-equiv="Content-Type"></head><body ><div style='font-size:10pt;font-family:Verdana,Arial,Helvetica,sans-serif;'>I'm fairly sure there is already a Perl module that does this<div id="message"></div><br id="br3"><div id="signature"></div><div id="content"><br> ---- On Tue, 14 Aug 2018 10:46:18 +0100 <b> gllug@mailman.lug.org.uk </b> wrote ----<br><br><blockquote style="border-left: 1px solid rgb(204, 204, 204); padding-left: 6px; margin-left: 5px;"><div>Dear list,<br><br>A problem which I think has a philosophical side as much as a practical one:<br>What is the best way (or what are the ways) to replace numbers written <br>out in words with digits?<br>(e.g. "the year one thousand eight hundred and seventy six" to 1776, or <br>"nine hundred and ninety pounds" to 999 pounds).<br><br>One obvious solution I've thought of is to automatically generate a list <br>of all numbers spelled out from one to n, pair them with the numerical <br>value, then simply loop through the list and target texts substituting <br>the former with the latter. But this strikes me as very blunt and very <br>uneconomical. And probably impracical in that the top most number may be <br>very high (I don't know what the highest number in the texts I have is, <br>though I have seen 'thirty-eight million nine hundred and ninety-seven').<br><br>Could there be a regex solution that generates the number from the words?<br><br>What other approaches could I take?<br><br>Thanks in advance,<br><br>John<br><br>-- <br><br>John Levin<br><a href="http://www.anterotesis.com" target="_blank">http://www.anterotesis.com</a><br><a href="http://twitter.com/anterotesis" target="_blank">http://twitter.com/anterotesis</a><br><a href="https://hcommons.org/members/johnlevin/" target="_blank">https://hcommons.org/members/johnlevin/</a><br><br>-- <br>GLLUG mailing list<br><a href="mailto:GLLUG@mailman.lug.org.uk" target="_blank">GLLUG@mailman.lug.org.uk</a><br><a href="https://mailman.lug.org.uk/mailman/listinfo/gllug" target="_blank">https://mailman.lug.org.uk/mailman/listinfo/gllug</a></div></blockquote></div></div><br></body></html>