Page 1 of 1

Divide the string into chunks

Posted: Thu Sep 29, 2011 4:43 am
by zintani
Hello Everybody,
Actually I have been searching and trying to find a way to divide the contents of my text document into parts depend on a sentence. If the sentence appears then the string is automatically divided.
For example, I went to the library to look for a book, which has information on how to use regex, the book which has the information, had been already borrowed.
If we say that book has information is our desired sentence then the code will do
the output will be
I went library look

(this is after removing stop words) and then it deletes all the words after that.

Re: Divide the string into chunks

Posted: Thu Sep 29, 2011 7:35 am
by Eric!
zintani wrote:"I went to the library to look for a book, which has information on how to use regex, the book which has the information, had been already borrowed."
If we say that book has information is our desired sentence then the code will do
the output will be
I went library look

(this is after removing stop words) and then it deletes all the words after that.
Regex doesn't understand grammar. In fact your example sentence is really two sentences. Regex uses patterns and "book has information" is not a pattern found in your two sentences easily because of the syntax of English. Perhaps if you explained more of what you are trying to do and what a "stop word" is we could try to help. Right now I see no logical way to search for your pattern and get the result you want.

Re: Divide the string into chunks

Posted: Thu Sep 29, 2011 8:13 am
by zintani
Thanks for your reply. What I meant was if there is a possible way to find a substring in a string. Stop words is another topic, has no relation with the question. Sorry to make it complicated.

Re: Divide the string into chunks

Posted: Thu Sep 29, 2011 1:25 pm
by AbraCadaver
strstr() If you have a better example with a little code it would be easier to help.