|
|||
Скачать ExtractWord - Извлечение слова из Строки
22.02.1995 {> Cut here. FileName= EXTRWORD.PAS } function ExtractWord(N : Byte; S : string; WordDelims : CharSet) : string; {-Given a set of word delimiters, return the N'th word in S} var I, Count, Len : Byte; SLen : Byte absolute S; begin Count := 0; I := 1; Len := 0; ExtractWord[0] := #0; while (I <= SLen) and (Count <> N) do begin {skip over delimiters} while (I <= SLen) and (S[I] in WordDelims) do Inc(I); {if we're not beyond end of S, we're at the start of a word} if I <= SLen then Inc(Count); {find the end of the current word} while (I <= SLen) and not(S[I] in WordDelims) do begin {if this is the N'th word, add the I'th character to Tmp} if Count = N then begin Inc(Len); ExtractWord[0] := Char(Len); ExtractWord[Len] := S[I]; end; Inc(I); end; end; end; | |||
© 2009–2024 Russian Pascal Developer Network.
Техническая площадка: ISBIZ Хостинг |