[Gambas-user] RE: Transform String

Marcus Moeller m.moeller at ...1299...
Sun Jan 8 10:44:58 CET 2006


Am Samstag, 7. Januar 2006 23:31 schrieb Rohnny Stormo:
> Hi.

Hi,

first I want to excuse my multiple post (I sent the frist one using a wrong 
eMail address and thought that the list did not acceppt that [as it should 
normally do, I guess]).

> 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)

It works with that little modification:

result = Mid(row, i + 1, j - i - 1)

>     end if
> end if
> Should result in 0

Thanks for your kind help.

Marcus




More information about the User mailing list