[Lazarus] Getting and setting the x numbered word in a sentence

John Landmesser JohnML at online.de
Wed Jan 8 18:33:34 CET 2014


On 07.01.2014 19:04, Richard Mace wrote:
>
> Hi,
> Is there an existing routine in Lazarus that will get and set 
> effectively the x numbered word in a sentence without actually knowing 
> what the actual word is?
> E.g with the string "the cat sat on the mat"
> You could say replace word 3 with string "stood" so the result would 
> be a string which was " the cat stood on the mat" even though you 
> didn't know that the 3rd word was originally "sat"?
> Hope that makes sense :)
> Thanks
> Richard
>

Have a look at functions in StrUtils like:

function WordCount(const S: string; const WordDelims: TSysCharSet): Integer;
function WordPosition(const N: Integer; const S: string; const 
WordDelims: TSysCharSet): Integer;
function ExtractWord(N: Integer; const S: string;  const WordDelims: 
TSysCharSet): string;inline;
function ExtractWordPos(N: Integer; const S: string; const WordDelims: 
TSysCharSet; var Pos: Integer): string;




More information about the Lazarus mailing list