Independant behavior for space separated words vs non-space delimiters (word functions)
This commit is contained in:
parent
f7c7fe4677
commit
c29159670e
|
@ -231,16 +231,29 @@ Begin
|
||||||
End;
|
End;
|
||||||
|
|
||||||
Function strWordCount (Str: String; Ch: Char) : Byte;
|
Function strWordCount (Str: String; Ch: Char) : Byte;
|
||||||
|
Var
|
||||||
|
Start : Byte;
|
||||||
Begin
|
Begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
|
|
||||||
|
If Ch = ' ' Then
|
||||||
|
While Str[1] = Ch Do
|
||||||
|
Delete (Str, 1, 1);
|
||||||
|
|
||||||
If Str = '' Then Exit;
|
If Str = '' Then Exit;
|
||||||
|
|
||||||
Result := 1;
|
Result := 1;
|
||||||
|
|
||||||
While Pos(Ch, Str) > 0 Do Begin
|
While Pos(Ch, Str) > 0 Do Begin
|
||||||
Inc (Result);
|
Inc (Result);
|
||||||
Delete (Str, Pos(Ch, Str), 1);
|
|
||||||
|
Start := Pos(Ch, Str);
|
||||||
|
|
||||||
|
If Ch = ' ' Then Begin
|
||||||
|
While Str[Start] = Ch Do
|
||||||
|
Delete (Str, Start, 1);
|
||||||
|
End Else
|
||||||
|
Delete (Str, Start, 1);
|
||||||
End;
|
End;
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
@ -281,16 +294,22 @@ Begin
|
||||||
Temp := Str;
|
Temp := Str;
|
||||||
|
|
||||||
If Ch = ' ' Then
|
If Ch = ' ' Then
|
||||||
While Pos(Ch, Temp) = 1 Do Delete (Temp, 1, 1);
|
While Temp[1] = Ch Do
|
||||||
|
Delete (Temp, 1, 1);
|
||||||
|
|
||||||
While Count < Num Do Begin
|
While Count < Num Do Begin
|
||||||
Start := Pos(Ch, Temp);
|
Start := Pos(Ch, Temp);
|
||||||
|
|
||||||
If Start = 0 Then Exit;
|
If Start = 0 Then Exit;
|
||||||
|
|
||||||
While Temp[Start] = Ch Do Inc (Start);
|
If Ch = ' ' Then Begin
|
||||||
|
While Temp[Start] = Ch Do
|
||||||
|
Inc (Start);
|
||||||
|
|
||||||
Delete (Temp, 1, Start - 1);
|
Dec(Start);
|
||||||
|
End;
|
||||||
|
|
||||||
|
Delete (Temp, 1, Start);
|
||||||
Inc (Count);
|
Inc (Count);
|
||||||
End;
|
End;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue