以前看到c#的正则,人民币转大写:
http://www.cnblogs.com/TianFang/archive/2012/08/09/2630912.html
转换成powershell:
function ctc([double]$num){ $s=$num.ToString("#L#E#D#C#K#E#D#C#J#E#D#C#I#E#D#C#H#E#D#C#G#E#D#C#F#E#D#C#.0B0A") $d=[Regex]::Replace($s,'((?<=-|^)[^1-9]*)|((?''z''0)[0A-E]*((?=[1-9])|(?''-z''(?=[F-L\.]|$))))|((?''b''[F-L])(?''z''0)[0A-L]*((?=[1-9])|(?''-z''(?=[\.]|$))))','${b}${z}') [Regex]::Replace($d,".",{param($str)"负元空零壹贰叁肆伍陆柒捌玖空空空空空空空分角拾佰仟萬億兆京垓秭穰"[[int][char]$str.Value - [int][char]'-'].ToString()}) } 1..100|%{$a=Get-Random 65535;[Convert]::tostring($a,2).substring(3).trimstart("0")}|%{$_ ctc $_} #测试
原文链接:https://www.f2er.com/regex/359735.html