[Gambas-user] convert string to collection
Gianluigi
gradobag at gradobag.it
Thu May 4 15:42:56 CEST 2023
Il 04/05/23 15:29, Gianluigi ha scritto:
> Il 04/05/23 14:44, Fabien Bodard ha scritto:
>> Dim a as string[]
>> For each s in split(s2)
>> a=scan(s,"*:*")
>> cRet[a[0]]=a[1]
>> Next
>>
>>
>> Best regards,
>> Fabien
>>
> Hi Fabien,
>
> Nice code, but I think it needs to be given:
> For Each s In Split(s2, "\n", Null, True)
>
> Regards
>
> Gianluigi
>
>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
Hi Fabien,
Sorry I made a mistake, it needs a Trim on a[1] :-(
Here is the code that works:
Dim cRet As New Collection
Dim a As String[]
Dim s2 As String = "Event: Hangup\nPrivilege: call, all\nChannel: SIP
/ 4 F2060EB4 - 00000000\nUniqueid: 1283174108.0\nCallerIDNum:
2565551212\nCallerIDName: Russell Bryant\nCause: 16\nCause - txt: Normal
Clearing"
For Each s As String In Split(s2, "\n")
a = Scan(s, "*:*")
cRet[a[0]] = Trim(a[1])
Next
Print cRet["Event"]
Print cRet["Privilege"]
Print cRet["Uniqueid"]
Regards 😘
Gianluigi
More information about the User
mailing list