[Gambas-user] Split a line with double spaces

user demosthenesk at ...626...
Fri Oct 15 15:35:02 CEST 2010


nice idea...

Thanks.

On Fri, 2010-10-15 at 15:18 +0200, Stefano Palmeri wrote:
> Il venerdì 15 ottobre 2010 13:26:13 user ha scritto:
> > Hi to all,
> >
> > i have a string which contains two spaces in a row.
> >
> > i use split function to split this string in 2 parts with separator the
> > 2 spaces.
> >
> > sOneLine="/mnt/store/RealViruses/minitest/Trojan-Spy.Win32.Zbot.hzu
> > Virus found Win32/Heur"
> >
> > sSplitLine = Split(sOneLine, ("  ")
> >
> > Normally i want to have
> >
> > sSplitLine[0]="/mnt/store/RealViruses/minitest/Trojan-Spy.Win32.Zbot.hzu"
> > sSplitLine[1]="Virus found Win32/Heur"
> >
> > but split uses the 2 spaces as one so i get
> >
> > sSplitLine[0]="/mnt/store/RealViruses/minitest/Trojan-Spy.Win32.Zbot.hzu"
> > sSplitLine[1]="Virus"
> > sSplitLine[2]="found
> > sSplitLine[3]="Win32/Heur"
> >
> > What must i do to get
> >
> > sSplitLine[0]="/mnt/store/RealViruses/minitest/Trojan-Spy.Win32.Zbot.hzu"
> > sSplitLine[1]="Virus found Win32/Heur"
> >
> > i have already tried to use some ascii code for space as
> > sSplitLine = Split(sOneLine, ((Chr(32) & Chr(32))))
> >
> > but no results
> > Any help?
> >
> 
> Split uses a single separator. You have to replace that double space "  "
> with a single uniq separator. For example a new line. Here's:
> 
> DIM sOneline AS String
>   DIM arsLines AS String[]
>   
>   sOneline = "/mnt/store/RealViruses/minitest/Trojan-Spy.Win32.Zbot.hzu  Virus 
> found Win32/Heur"
>   sOneline = Replace$(sOneline, "  ", "\n")
>   arsLines = Split(sOneline, "\n")
>     
>   PRINT arsLines[0] 
>   PRINT arsLines[1]
>   
> Ciao
>  
> 
> 
> 
> 
> 
> 
> >
> >
> > ---------------------------------------------------------------------------
> >--- Download new Adobe(R) Flash(R) Builder(TM) 4
> > The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
> > Flex(R) Builder(TM)) enable the development of rich applications that run
> > across multiple browsers and platforms. Download your free trials today!
> > http://p.sf.net/sfu/adobe-dev2dev
> > _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 
> 
> ------------------------------------------------------------------------------
> Download new Adobe(R) Flash(R) Builder(TM) 4
> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly 
> Flex(R) Builder(TM)) enable the development of rich applications that run
> across multiple browsers and platforms. Download your free trials today!
> http://p.sf.net/sfu/adobe-dev2dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user






More information about the User mailing list