Sign in to follow this  
Followers 0
P0ZiTR0N

StringRegExp need help

4 posts in this topic

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

Share this post


Link to post
Share on other sites



I think that's what you want :D

#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

Share this post


Link to post
Share on other sites

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
And 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)

Share this post


Link to post
Share on other sites

well.. its what I needed. Didn't know about "StringBetween" :D

Thanx for both versions.

StringRegExp($sIni, "\[(\d+)\]", 3)

would be used in the same script :o

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0