View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0035663 | FPC | Compiler | public | 2019-06-01 18:32 | 2019-06-03 08:36 |
Reporter | Ally | Assigned To | Michael Van Canneyt | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | no change required | ||
Platform | PC | OS | Windows | ||
Product Version | 3.0.4 | ||||
Summary | 0035663: For a string that ends with the delimiter, split returns one string too little. | ||||
Description | In my opinion Split should return three strings for a string with two delimiters, even if the last one is an empty string. | ||||
Steps To Reproduce | The following example is a nice way to try it out. procedure TForm1.Button1Click(Sender: TObject); var Zeile: String; Spalte: TStringArray; begin //Zeile := 'F0;F1;F2'; // High(Spalte) = 2 = Ok //Zeile := ';F1;F2'; // High(Spalte) = 2 = Ok //Zeile := ';;F2'; // High(Spalte) = 2 = Ok //Zeile := 'F0;;F2'; // High(Spalte) = 2 = Ok //Zeile := ';;'; // High(Spalte) = 1 = Falsch //Zeile := 'F0;F1;'; // High(Spalte) = 1 = Falsch //Zeile := 'F0;;'; // High(Spalte) = 1 = Falsch Zeile := ';F1;'; // High(Spalte) = 1 = Falsch Spalte := Zeile.Split(';'); LabelSpaltenIndex.Caption := IntToStr(High(Spalte)); Label_Index_0.Caption := Spalte[0]; Label_Index_1.Caption := Spalte[1]; Label_Index_2.Caption := Spalte[2]; end; | ||||
Tags | No tags attached. | ||||
Fixed in Revision | |||||
FPCOldBugId | |||||
FPCTarget | - | ||||
Attached Files |
|
duplicate of | 0035669 | resolved | Michael Van Canneyt | For a string that ends with the delimiter, split returns one string too little. |
|
I re-checked, the current behaviour is Delphi compatible. But I agree it is not logical behaviour. I have added a line to the documentation to make this clear. |
|
Update: It seems the behaviour became more logical in Delphi Rio, so I adapted the implementation to match Delphi Rio. (see related bugreport) It should now behave as you (and I :) ) expect ! |
Date Modified | Username | Field | Change |
---|---|---|---|
2019-06-01 18:32 | Ally | New Issue | |
2019-06-01 18:39 | Michael Van Canneyt | Assigned To | => Michael Van Canneyt |
2019-06-01 18:39 | Michael Van Canneyt | Status | new => assigned |
2019-06-02 11:39 | Michael Van Canneyt | Status | assigned => resolved |
2019-06-02 11:39 | Michael Van Canneyt | Resolution | open => no change required |
2019-06-02 11:39 | Michael Van Canneyt | FPCTarget | => - |
2019-06-02 11:39 | Michael Van Canneyt | Note Added: 0116528 | |
2019-06-02 18:54 | Michael Van Canneyt | Relationship added | duplicate of 0035669 |
2019-06-03 08:36 | Michael Van Canneyt | Note Added: 0116545 |