Thread: [Gambas-user] New behaviour for the Split() instruction
Brought to you by:
gambas
|
From: Benoît M. <ga...@us...> - 2014-11-29 21:14:08
|
I'm currently a new behaviour for the Split() instruction, that is
normally backward-compatible.
Split("abcd",";","\\;")
splits the "abcd" string with the ";" character, and uses the backslash
character for escaping it.
This behaviour is enabled when the escape string (the third argument)
has two characters, and its second character is the same as the first
splitting character (the second argument). Then the first character of
the escape string is the escape character (usually a backslash).
What do you think about that?
--
Benoît Minisini
|
|
From: Benoît M. <ga...@us...> - 2014-11-29 21:21:55
|
Le 29/11/2014 22:13, Benoît Minisini a écrit :
> I'm currently a new behaviour for the Split() instruction, that is
.
/|\
defining ------'
> normally backward-compatible.
>
> Split("abcd",";","\\;")
>
> splits the "abcd" string with the ";" character, and uses the backslash
> character for escaping it.
>
> This behaviour is enabled when the escape string (the third argument)
> has two characters, and its second character is the same as the first
> splitting character (the second argument). Then the first character of
> the escape string is the escape character (usually a backslash).
>
> What do you think about that?
>
--
Benoît Minisini
|
|
From: Tobias B. <ta...@gm...> - 2014-11-29 21:25:45
|
On Sat, 29 Nov 2014, Beno??t Minisini wrote:
> I'm currently a new behaviour for the Split() instruction, that is
> normally backward-compatible.
>
> Split("abcd",";","\\;")
>
> splits the "abcd" string with the ";" character, and uses the backslash
> character for escaping it.
>
> This behaviour is enabled when the escape string (the third argument)
> has two characters, and its second character is the same as the first
> splitting character (the second argument). Then the first character of
> the escape string is the escape character (usually a backslash).
>
> What do you think about that?
>
I have not found any use of a two-character escape string in my collective
projects. Therefore, no objection. (Although I don't really understand what
the change means. Do you have an example of what Split() gives before and
after your change, in a case where they're different?)
Regards,
Tobi
--
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
|
|
From: Benoît M. <ga...@us...> - 2014-11-29 21:39:48
|
Le 29/11/2014 22:22, Tobias Boege a écrit :
> On Sat, 29 Nov 2014, Beno??t Minisini wrote:
>> I'm currently a new behaviour for the Split() instruction, that is
>> normally backward-compatible.
>>
>> Split("abcd",";","\\;")
>>
>> splits the "abcd" string with the ";" character, and uses the backslash
>> character for escaping it.
>>
>> This behaviour is enabled when the escape string (the third argument)
>> has two characters, and its second character is the same as the first
>> splitting character (the second argument). Then the first character of
>> the escape string is the escape character (usually a backslash).
>>
>> What do you think about that?
>>
>
> I have not found any use of a two-character escape string in my collective
> projects. Therefore, no objection. (Although I don't really understand what
> the change means. Do you have an example of what Split() gives before and
> after your change, in a case where they're different?)
>
> Regards,
> Tobi
>
Before that, Split("abcd",";","\\;") did nothing useful, as an escape
character cannot be a splitting character. No error was raised in that
case, you just got some undefined behaviour.
So I decided to use that syntax to implement a different way of
splitting the string. Instead of escaping with enclosing characters
(everything between these two characters cannot be split), I escape
characters one by one with the special character indicated in the
beginning of the escape string.
Regards,
--
Benoît Minisini
|
|
From: B B. <bb...@pa...> - 2014-11-29 21:53:27
|
On Sat, 29 Nov 2014 22:22:23 +0100
Tobias Boege <ta...@gm...> wrote:
> On Sat, 29 Nov 2014, Beno??t Minisini wrote:
> > I'm currently a new behaviour for the Split() instruction, that is
> > normally backward-compatible.
> >
> > Split("abcd",";","\\;")
> >
> > splits the "abcd" string with the ";" character, and uses the backslash
> > character for escaping it.
> >
> > This behaviour is enabled when the escape string (the third argument)
> > has two characters, and its second character is the same as the first
> > splitting character (the second argument). Then the first character of
> > the escape string is the escape character (usually a backslash).
> >
> > What do you think about that?
> >
>
> I have not found any use of a two-character escape string in my collective
> projects. Therefore, no objection. (Although I don't really understand what
> the change means. Do you have an example of what Split() gives before and
> after your change, in a case where they're different?)
>
> Regards,
> Tobi
>
> --
> "There's an old saying: Don't change anything... ever!" -- Mr. Monk
>
Yes, I would like to see an example of before and after as well.
I think I had a need for exactly this the other day. I wanted to split a comma delimited list except where the comma is immediately followed by a space. Will this change help that?
regards
Bruce
--
B Bruen <ada...@gm...>
|
|
From: Benoît M. <ga...@us...> - 2014-11-29 22:03:55
|
Le 29/11/2014 22:53, B Bruen a écrit : > > Yes, I would like to see an example of before and after as well. > > I think I had a need for exactly this the other day. I wanted to > split a comma delimited list except where the comma is immediately > followed by a space. Will this change help that? > > regards Bruce > No. It's for splitting such string with the ';' character: "blue;blue\\;yellow;green" to get: ["blue","blue;yellow","green"] -- Benoît Minisini |