P0ZiTR0N Posted April 12, 2009 Share Posted April 12, 2009 Hi, all. Tried by myself but no result... need to read cycle of data in brackets []. Tried a lot of variations of StringRegExp... Nothing worked properly, so the request is to help configure StringRegExp. Thanx to all input-data: parse.ini: [DATA] Item=2528286[326083] Item=2496182[33728] Item=2496196[3378] Item=2508154[33] Item=2537685[344753] #include <Array.au3> $dx = _ArrayCreate("") $datafile = @ScriptDir & "\parse.ini" $arr_ini = IniReadSection($datafile, "DATA") Global $c, $output $c = 0 If @error Then ;~ MsgBox(4096, "", "Error!") Else For $c = 1 To $arr_ini[0][0] _ArrayAdd($dx, $arr_ini[$c][0] & "=" & $arr_ini[$c][1]) Next EndIf _ArrayReverse ($dx) _ArrayPop($dx) ;~ _ArrayDisplay($dx) $dv = UBound($dx)-1 For $c=0 to $dv step 1 $output = _ArrayPop($dx) & @LF $output = StringTrimLeft($output,StringRegExp($output,'[')) $output = StringTrimRight($output,StringRegExp($output,']')) ConsoleWrite($output & @CRLF) Next $c = 0 Link to comment Share on other sites More sharing options...
Dampe Posted April 12, 2009 Share Posted April 12, 2009 I think that's what you want #include <Array.au3> #include <String.au3> $dx = _ArrayCreate("") $datafile = @ScriptDir & "\parse.ini" $arr_ini = IniReadSection($datafile, "DATA") Global $c, $output $c = 0 If @error Then ;~ MsgBox(4096, "", "Error!") Else For $c = 1 To $arr_ini[0][0] _ArrayAdd($dx, $arr_ini[$c][0] & "=" & $arr_ini[$c][1]) Next EndIf _ArrayReverse ($dx) _ArrayPop($dx) ;~ _ArrayDisplay($dx) $dv = UBound($dx)-1 For $c=0 to $dv step 1 $output = _ArrayPop($dx) & @LF $output = _StringBetween ($output, "[", "]") ConsoleWrite($output[0] & @CRLF) Next $c = 0 Link to comment Share on other sites More sharing options...
Malkey Posted April 12, 2009 Share Posted April 12, 2009 Hi, all. Tried by myself but no result... need to read cycle of data in brackets []. Tried a lot of variations of StringRegExp... Nothing worked properly, so the request is to help configure StringRegExp. Thanx to all input-data: parse.ini: [DATA] Item=2528286[326083] Item=2496182[33728] Item=2496196[3378] Item=2508154[33] Item=2537685[344753] #include <Array.au3> $dx = _ArrayCreate("") $datafile = @ScriptDir & "\parse.ini" $arr_ini = IniReadSection($datafile, "DATA") Global $c, $output $c = 0 If @error Then ;~ MsgBox(4096, "", "Error!") Else For $c = 1 To $arr_ini[0][0] _ArrayAdd($dx, $arr_ini[$c][0] & "=" & $arr_ini[$c][1]) Next EndIf _ArrayReverse ($dx) _ArrayPop($dx) ;~ _ArrayDisplay($dx) $dv = UBound($dx)-1 For $c=0 to $dv step 1 $output = _ArrayPop($dx) & @LF $output = StringTrimLeft($output,StringRegExp($output,'[')) $output = StringTrimRight($output,StringRegExp($output,']')) ConsoleWrite($output & @CRLF) Next $c = 0And here is another solution. #include <Array.au3> Local $sIni, $output $datafile = @ScriptDir & "\parse.ini" $arr_ini = IniReadSection($datafile, "DATA") ;_ArrayDisplay($arr_ini) For $c = 1 To UBound($arr_ini) - 1 $sIni &= $arr_ini[$c][0] & "=" & $arr_ini[$c][1] & "|" Next ;ConsoleWrite(@CRLF & $sIni & @CRLF) $output = StringRegExp($sIni, "\[(\d+)\]", 3) _ArrayDisplay($output) Link to comment Share on other sites More sharing options...
P0ZiTR0N Posted April 12, 2009 Author Share Posted April 12, 2009 well.. its what I needed. Didn't know about "StringBetween" Thanx for both versions. StringRegExp($sIni, "\[(\d+)\]", 3)would be used in the same script Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now