当前位置:网站首页>js数字大写方法
js数字大写方法
2022-04-23 05:36:00 【晴天暖宝宝】
js实现数字大写的方法:
capitalMoney(num) {
var strOutput = '';
var strUnit = '仟佰拾亿仟佰拾万仟佰拾元角';
num += '0';
var intPos = num.indexOf('.');
if (intPos >= 0) {
num = num.substring(0, intPos) + num.substr(intPos + 1, 1);
}
strUnit = strUnit.substr(strUnit.length - num.length);
for (var i = 0; i < num.length; i++) {
strOutput +=
'零壹贰叁肆伍陆柒捌玖'.substr(num.substr(i, 1), 1) +
strUnit.substr(i, 1);
}
return strOutput
.replace(/零角$/, '整')
.replace(/零[仟佰拾]/g, '零')
.replace(/零{2,}/g, '零')
.replace(/零([亿|万])/g, '$1')
.replace(/零+元/, '元')
.replace(/亿零{0,3}万/, '亿')
.replace(/^元/, '零元');
}
版权声明
本文为[晴天暖宝宝]所创,转载请带上原文链接,感谢
https://blog.csdn.net/txun123/article/details/124357281
边栏推荐
- AcWing 836. Merge set (merge set)
- solidity合约DOS攻击
- shell指令学习1
- Frequently asked interview questions - 1 (non technical)
- The prefix of static of egg can be modified, including boots
- College entrance examination volunteer filling reference
- Create a tabbar component under the components folder, which is public
- Introduction to qqueue
- AcWing 1096. Detailed notes of Dungeon Master (3D BFS) code
- Sword finger offer II 022 The entry node of the link in the linked list
猜你喜欢

双击.jar包无法运行解决方法

what is wifi6?

分支与循环语句

Excel sets row and column colors according to cell contents

Breadth first search topics (BFS)

Necessity of selenium preloading cookies

Cross domain CORS relationship~

Generation of straightening body in 3D slicer

Cross platform packaging of QT packaging program

QT drawpixmap and DrawImage blur problem
随机推荐
修仙真实世界与游戏世界
Various situations of data / component binding
What financial products will benefit during May Day?
Relative reference and absolute reference of Excel
selenium预先加载cookie的必要性
Getting started with varnish
QSslSocket::connectToHostEncrypted: TLS initialization failed
acwing854. Floyd finds the shortest path
Create process memory management copy_ Mm - processes and threads (IX)
合约锁仓漏洞
Deep learning object detection
Redis in node -- ioredis
Radar equipment (greedy)
Reading notes of modern methods of C language programming
弘玑|数字化时代下,HR如何进行自我变革和组织变革?
xxl-job采坑指南xxl-rpc remoting error(connect timed out)
Qwebsocket communication
Several examples of pointer transfer, parameter transfer, value transfer, etc
Add two pointers? (legal or illegal)
Requirements for SQL server to retrieve SQL and user information