Didi.04-9-10 Teacher's Day
Function splitex (const str {requires a split article}, Delimiters {split keyword, Enter.?! etc.}: string: tstringlist;
VAR
SS: WideString;
I, st: integer;
Function isdelimiter (Const Delimiters, C: String): Boolean;
Begin // Judging whether it is a split key
Result: = STRSCAN (Pchar (Delimiters), C [1]) <> nil;
END;
Begin
Result: = TSTRINGLIST.CREATE;
WITH RESULT DO
Begin
Clear; sORTED: = true; duplicates: = dupignore DUPIGNORE
END;
IF Length (STR) <1 THEN EXIT;
SS: = Str; // Double character support, pure English can go
ST: = -1;
For i: = 1 to Length (ss) DO
IF Isdelimiter (Delimiters, SS [I]) THEN
IF ST <> -1 Then
Begin
Result.Add (TRIM (Copy (SS, ST, I - ST)));
ST: = -1;
end
Else
IF st = -1. ST: = I;
IF st <> -1 Then Result.Add (Copy (SS, ST, Length (STR)));
END;
// Operation Demo
With splitex (Memo1.text, ',,.?!' # 13 # 10) DO
Try
Savetofile ('c: /TEMP_DEMO.TXT');
Finally
FREE;
END;