Jump to content

Get one part out a array line


Recommended Posts

Yep another question from me :)

I got a new array, and i search'd for a function that can do what i want. I found this one:

StringRegExp ( "test", "pattern" [, flag ] [, offset ] ] )

Now comes the tricky part, i got this in a Array

[0] = 87777347527528374523534533245723"0.0.0.0""name""name"

[1] = 8734727576435723423653245546"0.0.0.0""name2""name2"

[2] = 98743757824375273435686583773"0.0.0.0""igotnoname""igotnoname"

I want to get the "name","name2","igotnoname" out of the array, and put it in a other array2:

[0] = name

[1] = name2

[2] = igotnoname

I found out that there is a problem because the "", it closes the function in StringRegExp. So i cant put it in a For lus with because it closes himself. Does someone know if there is a possibility to get the "names" out of the array? Or is there a other function?

tnx,

xzaz

Link to comment
Share on other sites

You can include quotes in a string parameter of a function call in two different ways.

Double them up:

ConsoleWrite("This is an example of ""quotes"" used in a string.")oÝ÷ ÙK²)àꮢ׬¶§rZ,^²Ú⮶­sd6öç6öÆUw&FRb33µF22âW×ÆRöbgV÷C·V÷FW2gV÷C²W6VBâ7G&ærâb33²

Keep in mind that if you use single quotes to enclose the string, you need to double those up if you want to use them inside the string.

Link to comment
Share on other sites

Maybe...

Dim $Info[3]

$Info[0] = '87777347527528374523534533245723"0.0.0.0""name""name"'
$Info[1] = '8734727576435723423653245546"0.0.0.0""name2""name2"'
$Info[2] = '98743757824375273435686583773"0.0.0.0""igotnoname""igotnoname"'


for $x = 0 to UBound($Info) -1
    $Split = StringSplit($Info[$x], '""')
    $Info[$x] = $Split[6]
Next



;I want to get the "name","name2","igotnoname" out of the array, and put it in a other array2:

;[0] = name
;[1] = name2
;[2] = igotnoname


for $x = 0 to UBound($Info) -1
    MsgBox(0x0, "Info #" & $x, $Info[$x] , 3)
Next

8)

NEWHeader1.png

Link to comment
Share on other sites

Ok, first tnx for the script. I just think to hard. It can be very simple :)

I got this now:

$rules = UBound($array2)-1 
for $i=$rules to 0 step -1
    if $Array2[$i] = "" Then
            _ArrayDelete($Array2,$i) 
                                                    
            Endif
Next
;Here comes the data out of the Array whats in my first post
$rules2 = UBound($Array2)-1
Dim $Info[$rules2]
                                            
for $x = 0 to UBound($Info) -1
$Split = StringSplit($Info[$x], '""')
NExt 
_ArrayDisplay($Split,"Test")

On this way i only get a "1" in a array.

Whats wrong here?

Link to comment
Share on other sites

  • Moderators

StringRegExp($Info[$x], '""(.*?)""', 1) should work as well.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Ok, first tnx for the script. I just think to hard. It can be very simple :)

I got this now:

$rules = UBound($array2)-1 
for $i=$rules to 0 step -1
    if $Array2[$i] = "" Then
            _ArrayDelete($Array2,$i) 
                                                    
            Endif
Next
;Here comes the data out of the Array whats in my first post
$rules2 = UBound($Array2)-1
Dim $Info[$rules2]
                                            
for $x = 0 to UBound($Info) -1
$Split = StringSplit($Info[$x], '""')
NExt 
_ArrayDisplay($Split,"Test")oÝ÷ Øéí+0k(¨ zÖªºuªê-v®¶²Z­³
è^­ïêº^N¼ºÚ"µÍØ^Y^XÝ]LÂÚ[ÛYIØ^K]LÉÝÂØØ[    ÌÍØ^LÌ×HHÉÌÎNÎ
ÍÍÍÌÍ
ÍLÍLÍÍ
LÍLÍ
LÌÌ
MÌÉ][ÝÌ ][ÝÉ][ÝÛ[YI][ÝÉ][ÝÛ[YI][ÝÉÌÎNËÂBIÌÎNÎ
ÌÍ
ÌÍMÍÍMÌÍÍLÌ
MM
][ÝÌ  ][ÝÉ][ÝÛ[YL][ÝÉ][ÝÛ[YL][ÝÉÌÎNËÂBIÌÎNÎN
ÍÍÍMÎÍÍLÌÍÍM
NÍÍÌÉ][ÝÌ ][ÝÉ][ÝÚYÛÝÛ[YI][ÝÉ][ÝÚYÛÝÛ[YI][ÝÉÌÎN×BØØ[ ÌÍÒ[ÖÕPÝ[
    ÌÍØ^LWBÜ    ÌÍÞHÈPÝ[
    ÌÍØ^LHHBIÌÍÔÜ]HÝ[ÔÜ]
    ÌÍØ^LÉÌÍÞK   ÌÎNÉ][ÝÉ][ÝÉÌÎNËJBWÐ^QÜ^J   ÌÍÔÜ]   ][ÝÕÝÈÜ    ÌÍÞI][ÝÉ[ÉÌÍÞ  [É][ÝÉÌÍÔÜ]ÌOI][ÝÉ[ÉÌÍÔÜ]ÌJBZYØ^J  ÌÍÔÜ]
H[  ÌÍÒ[ÖÉÌÍÞOIÌÍÔÜ]ÌB^Ð^QÜ^J    ÌÍÒ[Ë   ][ÝÕÝÜ  ÌÍÒ[É][ÝÊ
Randall
Link to comment
Share on other sites

@Smoke:

Tnx, i will try to implementate that in the script.

@Randall:

omg, i will test that script, and see what i can do with it. Its a step higher then what i'v scripted before but i can take a look.

The next problem is, is that the $Array2 is not a constant Array number. I hope i dont make the feeling that you guys are scripting for me, that i dont work for it. I'll try to understand the above script. And tnx for the help. :)

Link to comment
Share on other sites

Im comming closer:

$lines = Ubound($Array2) -1
msgBox(0,"Lines",$lines)
;_ArrayDisplay($Array2,"test")
Local $Info[UBound($Array2)-1]
For $x = 0 To $lines
;   msgBox(0,"|Test",$Array2[$x])
    $Split = StringSplit($Array2[$x], '""',1)

    if isarray($Split) then $Info[$x]=$Split[2]
Next
_ArrayDisplay($Info, "Test for $Info")

And this is the error:

==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

if isarray($Split) then $Info[$x]=$Split[2]

if isarray($Split) then $Info[$x]=^ ERROR

This is my script now, ofcourse it dosnt work but it seems like he is picking the Array2 now. The first msgbox takes a good count. Its now 2. The array display (from $Array2) gives me now:

34728374927947529384752"0.0.0.0""name43""Name43"

8947502938475247274617236"0.0.0.0""name33""Name33"

I got a problem with getting $Array2 in the script.

Edited by xzaz
Link to comment
Share on other sites

Im comming closer:

$lines = Ubound($Array2) -1
msgBox(0,"Lines",$lines)
;_ArrayDisplay($Array2,"test")
Local $Info[UBound($Array2)-1]
For $x = 0 To $lines
;   msgBox(0,"|Test",$Array2[$x])
    $Split = StringSplit($Array2[$x], '""',1)

    if isarray($Split) then $Info[$x]=$Split[2]
Next
_ArrayDisplay($Info, "Test for $Info")oÝ÷ Ø  ݶ¬Ëayê뢴áȬ+®*m(}Ê.®Ç¢µÚ,Ü(®Fî¶+lyé¬)謦'$x-à+­¬¶çâ®Ëf²èÆÖ¤zÆ ¢¢éí"Û'£
æ«­¬Êek'ë¢m7è
ëk- ÷¬éèÃ~;ÛÍûãÝ»÷ùÛÝüã¾vªê-ÓM4ªê-ªê-©ãz®¢Ú®¢ÓZî7ªê-óÞ;çM½ßÎ;çn;Û¾:×½·ê«¨·M4Ò«¨¶«¨¶v¦{}êºjºMjg·Þ«¨´(µªk¡¹^­­¶)àÓ~®¶²Ú)íë®*mþ«¨µæ®¶­sfb6'&b33cµ7ÆBæBT&÷VæBb33cµ7ÆBfwC³"FVâb33c´æfõ²b33c·ÓÒb33cµ7ÆE³%
Some lines don't have the info you need...

Randall

Link to comment
Share on other sites

  • Moderators

Following Randalls lead here...

#include <array.au3>
local $aArray[3] = ['87777347527528374523534533245723"0.0.0.0""name""name"', _
        '8734727576435723423653245546"0.0.0.0""name2""name2"', _
        '98743757824375273435686583773"0.0.0.0""igotnoname""igotnoname"']
Local $iAdd = 1, $aInfo[UBound($aArray) + 1]
For $iCC = 0 To UBound($aArray) - 1
    $aSRE = StringRegExp($aArray[$iCC], '""(.*?)""', 1)
    If IsArray($aSRE) Then
        $aInfo[$iAdd] = $aSRE[0]
        $iAdd += 1
    EndIf
Next
$aInfo[0] = $iAdd
ReDim $aInfo[$iAdd]
_ArrayDisplay($aInfo, "Test for $Info")

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...