本脚本来自于Thinkai的博客,仅作为归档。
conv2num(str){
d := {"零":0,"一":1,"二":2,"两":2,"三":3,"四":4,"五":5,"六":6,"七":7,"八":8,"九":9,"十":10,"百":100,"千":1000,"万":10000,"亿":100000000}
n = 0
a := StrSplit(str,"亿")
if a[2]
{
b := StrSplit(a[2],"万")
s1 := a[1],s2 := b[1], s3 := b[2]
}
else
{
a := StrSplit(str,"万")
s1 := a[1],s2 := a[2], s3 := ""
}
l1 := InStr(str,"亿") ? d["亿"] : (InStr(str,"万") ? d["万"] : 1)
l2 := InStr(a[2],"万") ? d["万"] : (a[2] ? 1 : 0)
l3 := b[2] ? 1 : 0
if l1=1
{
Loop
{
if !str
break
if RegExMatch(str,"^(一|二|两|三|四|五|六|七|八|九)(十|百|千|)(.*)",m)
{
t := d[m1] * (m2 ? d[m2] : 1)
n += t, str := m3
}
else if RegExMatch(str,"^十(一|二|两|三|四|五|六|七|八|九|)$",m)
{
t := 10 + (m1 ? d[m1] : 0)
n += t, str := ""
}
else if RegExMatch(str,"^零(.*)",m)
str := m1
}
}
else
n := conv2num(s1)*l1 + conv2num(s2)*l2 + conv2num(s3)*l3
return n
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
真好