Recommend this page to a friend! |
Download .zip |
Info | View files (4) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2013-09-25 (3 years ago) | Not enough user ratings | Total: 298 | All time: 6,997 This week: 614 |
Version | License | PHP version | Categories | |||
ses-tokenizer 1.0 | GNU General Publi... | 5.3 | PHP 5, Text processing, Parsers |
Description | Author | ||||||||||||||
This class can parse and split a string into tokens. |
|
tokenizer ========= The Tokenizer class allows us to split an string into tokens. Unlike other classes, it is based on regular expressions. The 'match' function is the most important function of the class. It allows to split an string into tokens and accepts a regular expression as parameter. For example: ```php // splits an string into 'words' $t = new Tokenizer("Lorem ipsum dolor sit amet"); while (list($token) = $t->match("\w+")) { echo "$token-"; } ``` Note that you DO NOT NEED to write an explicit regular expression. In the above example, instead of typing "/^\s*\w+/" we can write "\w+". In this case, the function ignores the left spaces and start searching from the current offset position. In any case, you can use an explicit regular expresion: ```php // uses an explicit regular expression $t = new Tokenizer("I'm 35 years old"); if (list($years) = $t->match("/\d+/")) { echo "You are $years old"; } ``` |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
Tokenizer test Tokenizer test |
If you know an application of this package, send a message to the author to add a link here.