回复 3# lixiaolong
先谢谢你 但你这并不是我想要的结果 下面是我的代码 我就是觉得写的比较麻烦
$Str = _
'4566.132.435' & @CRLF & _
'-4566.1-32.435' & @CRLF & _
'45661-32435' & @CRLF & _
'.4566132435' & @CRLF & _
'-.4566132435' & @CRLF & _
'-4566132435.' & @CRLF & _
'-45661.32435' & @CRLF & _
'-456a61.32435' & @CRLF & _
'4566132435'
Local $out
$Test = StringRegExp($Str, "([^\v|$]+)", 3)
For $i = 0 To UBound($Test) - 1
$sr = StringRegExp($Test[$i], '\-|\.', 3)
If @error Then
If StringRegExpReplace($Test[$i], "\d", "") = "" Then $out &= $Test[$i] & @CRLF
Else
If StringRegExpReplace($Test[$i], "\d|\.|\-", "") = "" Then
If UBound($sr) = 1 Then
If StringRight($Test[$i], 1) = "-" Then $out &= $Test[$i] & @CRLF
If StringLeft($Test[$i], 1) = "." Then $out &= "0" & $Test[$i] & @CRLF
If StringRight($Test[$i], 1) = "." Then $out &= StringTrimRight($Test[$i], 1) & @CRLF
ElseIf UBound($sr) = 2 Then
If (Not StringInStr($Test[$i], "-", 0, 2)) Or (Not StringInStr($Test[$i], ".", 0, 2)) Then
If StringLeft($Test[$i], 1) = "-" Then
If StringLeft($Test[$i], 2) = "-." Then
$out &= StringRegExpReplace($Test[$i], "\-", "\-0") & @CRLF
ElseIf StringRight($Test[$i], 1) = "." Then
$out &= StringTrimRight($Test[$i], 1) & @CRLF
Else
$out &= $Test[$i] & @CRLF
EndIf
EndIf
EndIf
EndIf
EndIf
EndIf
Next
MsgBox(0, 0, $out)
|