hidrau
asked on
I need a function to split sentence
Hello guys
I have a function that split my sentence in words
procedure SplitString (const Delimiter: Char; Input: string; const Strings: TStrings) ;
begin
Assert(Assigned(Strings));
Strings.Clear;
Strings.Delimiter := Delimiter;
Strings.DelimitedText := Input;
end;
But I need something more clever, imagine a sentence like this:
Phr := "I am here working with my sister and she is working right now"
The procedure should work this way
procedure SplitSentence(Sentence: String, SplitNumber: Integer, const Strings: TStrings)
SplitNumber is the number words together, example:
SplitSentence(Phr, 2, List);
the sentence will be split in group of two words, something like this:
I am
here working
with my
sister and
she is
working right
now
As you can see, the last word is odd, then as it is the last, it can be without any group.
I hope you understand what I need.
I thank
Alexandre
I have a function that split my sentence in words
procedure SplitString (const Delimiter: Char; Input: string; const Strings: TStrings) ;
begin
Assert(Assigned(Strings));
Strings.Clear;
Strings.Delimiter := Delimiter;
Strings.DelimitedText := Input;
end;
But I need something more clever, imagine a sentence like this:
Phr := "I am here working with my sister and she is working right now"
The procedure should work this way
procedure SplitSentence(Sentence: String, SplitNumber: Integer, const Strings: TStrings)
SplitNumber is the number words together, example:
SplitSentence(Phr, 2, List);
the sentence will be split in group of two words, something like this:
I am
here working
with my
sister and
she is
working right
now
As you can see, the last word is odd, then as it is the last, it can be without any group.
I hope you understand what I need.
I thank
Alexandre
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
If I put only one, the last word repeats, why?
ASKER
Cynna, it is perfect :))
very good
Johnjces, thanks for your support too , only the last word is being repeated. Take a look at it
very good
Johnjces, thanks for your support too , only the last word is being repeated. Take a look at it
ASKER
hello cynna
I remember you. You have made this function to me
https://www.experts-exchange.com/questions/22859109/Function-to-Find-word-in-richedit.html
I am having problem on it, when I try to find two our three words
can you see it for me? if you want I can open another thread.
thanks
I remember you. You have made this function to me
https://www.experts-exchange.com/questions/22859109/Function-to-Find-word-in-richedit.html
I am having problem on it, when I try to find two our three words
can you see it for me? if you want I can open another thread.
thanks
Hi hidrau from Brasil :-)
For the sake of completness, please go to original question (https://www.experts-exchange.com/questions/22859109/Function-to-Find-word-in-richedit.html)
And we'll continue there, OK?
For the sake of completness, please go to original question (https://www.experts-exchange.com/questions/22859109/Function-to-Find-word-in-richedit.html)
And we'll continue there, OK?
It has some issues in the last string depending upon the number of splits, but hopefully you get the idea.
John