[Gambas-user] Split Strings
Rob Kudla
sourceforge-raindog2 at ...94...
Sat Jan 7 21:00:20 CET 2006
On Sat January 7 2006 11:12, Marcus Moeller wrote:
> 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
You can do it all with split, but it's so involved that I think a
regexp would be easier.
dim a as array
dim b as array
dim c as array
dim t as string
dim thedesiredvalue as integer
t = "IPADDR[1]=\"192.168.1.10\""
a = split(t, "=") ' a[0] = IPADDR[1], a[1] = "192.168.1.10"
b = split(a[0], "[") ' b[0] = IPADDR, b[1] = 1]
c = split(b[1], "]") ' c[0] = 1, there shouldn't be a c[1]
thedesiredvalue = val(c[0])
Rob
More information about the User
mailing list