[Gambas-user] RE: Transform String

Rohnny Stormo rohnny at ...1248...
Sat Jan 7 23:31:11 CET 2006


Hi.

What about:
dim s as string ="IPADDR[0]='192.168.1.10' "
dim i,j as integer
dim result as integer

'look for first ocurence of [
i = instr(s,"[")
'If exist, should be 6
if i>0 then
    'Look for first ocurence of ] after position where [ where found
    j = instr(s,"]",i)
    'if found and position are higher, should be 8
    if j>i then
         'Get the result from pos(i) to pos(j) Substract pos(i) -1
          'should get 8-6-1=1
         result = Mid(s,i,j-i-1)
    end if
end if
Should result in 0

Rohnny




More information about the User mailing list