#Include <Array.au3>
Dim $str = "名称 单价 数量 总价" & @CRLF & _
"这个是商品 10.00 1 10.00" & @CRLF & _
"这个是sssss 10.00 1 10.00"
While Not (StringInStr($str, " ") = 0)
$str = StringReplace($str, " ", " ")
WEnd
Dim $sstr = StringSplit($str,@CRLF,3)
Local $temp2=""
For $li In $sstr
$temp =StringSplit($li," ",2)
For $zz In $temp
$temp2 = $temp2 & StringFormat ("%-"&(20-get_cn_number($zz))&"s",$zz )
next
$temp2=$temp2& @CRLF
Next
ConsoleWrite($temp2)
MsgBox(0,"",$temp2)
Func get_cn_number($temp);获取字符串中中文字符的个数
Local $array = StringRegExp($temp, "[\x{4e00}-\x{9fa5}]", 3)
Return UBound($array)
EndFunc
|