Divide the string into chunks

Any questions involving matching text strings to patterns - the pattern is called a "regular expression."

Moderator: General Moderators

Post Reply
zintani
Forum Newbie
Posts: 2
Joined: Thu Sep 29, 2011 4:29 am

Divide the string into chunks

Post 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.
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Divide the string into chunks

Post 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.
zintani
Forum Newbie
Posts: 2
Joined: Thu Sep 29, 2011 4:29 am

Re: Divide the string into chunks

Post 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.
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Divide the string into chunks

Post by AbraCadaver »

strstr() If you have a better example with a little code it would be easier to help.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply