[Gambas-user] Split Strings
Benoit Minisini
gambas at ...1...
Mon Jan 9 00:41:16 CET 2006
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,
--
Benoit Minisini
More information about the User
mailing list