Numbertext / libnumbertext

Number to number name and money text conversion libraries in C++, Java, JavaScript and Python & LibreOffice Calc Extension
BSD 3-Clause "New" or "Revised" License
67 stars 46 forks source link

Make "hybrid" money text format #56

Open mikekaganski opened 5 years ago

mikekaganski commented 5 years ago

Hi!

I'm having trouble creating a rule for Russian money format required by our gvmt: for 1234.56, it must return "one thousand two hundred thirty-three roubles 54 kopecks" - note the number of kopecks is not in text. Could you please advise?

laszlonemeth commented 5 years ago

The English module contains a similar alternative version called "money":

"money USD 1234.56" results "one thousand two hundred thirty-four and 56/100 U.S. dollars"

inserting the cents (4th regex group) without conversion using \4:

no cents

"([A-Z]{3}) ([-−]?1)" $2$(\1:us) "([A-Z]{3}) ([-−]?\d+)" $2$(\1:up)

with cents

"(([A-Z]{3}) ([-−]?\d+)).," $3 and 1/100$(\2:us) "(([A-Z]{3}) ([-−]?\d+)).," $3 and \40/100$(\2:up) "(([A-Z]{3}) ([-−]?\d+)).," $3 and \4/100$(\2:up) "(([A-Z]{3}) ([-−]?\d+)).," $3 and \4/1000$(\2:up)