[Gambas-user] Split Strings

Werner Staudacher gambas-user at lists.sourceforge.net
Mon Jan 9 20:39:58 CET 2006


Benoit Minisini schrieb:

>On Monday 09 January 2006 00:13, Werner Staudacher wrote:
>  
>
>>mm at ...1313... schrieb:
>>    
>>
>>>Hi Gambas Users,
>>>
>>>I have got an array containing some string in the following format:
>>>
>>>IPADDR[0]="192.168.1.10"
>>>NETMASK[0]="255.255.255.0"
>>>IPADDR[1]="192.168.10.16"
>>>NETMASK[1]="255.255.255.248"
>>>...
>>>
>>>
>>>I need to isolete the number within [] and transform it to an integer
>>>variable. Can I use the split command or do I have do use regexp
>>>
>>>Best Regards
>>>Marcus
>>>      
>>>
>>Hi Marcus
>>
>>Split does not work for this sense.
>>Regexp is allways a good solution to extract a part within strings.
>>A simple solution i have see ones somewhere could also be: numb = val(
>>mid( somestring, instr(somestring,"[")+1 ) ), but is maybe more vb like
>>then gambas.
>>
>>Regards, staudi
>>
>>    
>>
>
>Split(IPADDR[0], ".") works.
>
>And, in the development version, you can use the Scan() routine too, which 
>manage the same basic regexp than LIKE:
>
>Scan(IPADDR[0], "*.*.*.*") will return [ "192", "168", "1", "10" ]
>
>Regards,
>
>  
>
I think he asked to get the number between the brackets  "IPADDR [ 0 ] 
="192.168.1.10"" wich would be the index of same kind of entries.

Regards, staudi




More information about the User mailing list