[Gambas-user] RC2 split Function (same as in RC1, may be before also)

Benoit Minisini gambas at ...1...
Tue Nov 9 11:07:19 CET 2004


On Monday 08 November 2004 23:11, Mike Keehan wrote:
> Charlie Reinl wrote:
> >>Charlie Reinl wrote:
> >>>Salut Benoit,
> >>>
> >>>take that line :
> >>>
> >>>Picture = Picture["gambas.png"]
> >>>
> >>>and split here by "="
> >>>
> >>>from sLine = "Picture = Picture[\"gambas.png\"]
> >>>
> >>>you get
> >>>"Picture " and " Picture[\"gambas.png\"]"
> >>>"Picture" and "Picture[\"gambas.png\"]"
> >>>thats it, you should get .
> >>>
> >>>The blanks left- and right from '=' should not be in the results.
> >>>
> >>>NO?
> >>>
> >>>Amicalment
> >>>Charlie
> >>
> >>No, I don't think so.
> >>
> >>If the 'split' string is " = " (that is, space - equals - space) then
> >>you would get what you want, but splitting by "=" alone should leave
> >>all the other characters in the split up strings, including leading an
> >>trailing spaces.
> >>
> >>If you need to get rid of the spaces, you can use Trim().
> >>
> >>Mike.
> >
> > Sorry,
> >
> > but what is the return if I split with a blank (' ')
> > sLine = "Picture = Picture[\"gambas.png\"]    "
> >
> > Picture
> > =
> > Picture[\"gambas.png\"]
> > ' '
> > ' '
> >
> > unquated blanks have no value, so they must be striped.
> >
> > Amicalment
> > Charlie
>
> I disagree.  Blanks _do_ have a value, they are part of the string.
>
> The only character that should not be in the output is the separator.
>   All other characters should still be in the output strings.
>
> If the space characters are not wanted in your application, then use
> Trim() to remove them.  Other people will want the spaces - I
> certainly do in some places.  And when I don't want leading/trailing
> spaces, I use trim().
>
> Try split() in other languages - awk, VB, or strtok() in C.  They all
> keep the space characters in the output strings when the separator is
> a single character (but not a space char - this tends to be special).
>
> Mike.
>

I think you will have what you want with the upcoming Perl-Compatible Regular 
Expression component from Rob Kudla. Be patient!

Regards,

--
Benoit Minisini
mailto:gambas at ...1...




More information about the User mailing list