public static function SuggestionHelper::tokenize in Autocomplete Search Suggestions 7
Tokenize the text into space separated lowercase strings.
Parameters
string $txt: The text to process.
int $min: The minimum number of characters in a token.
Return value
string The tokenized string.
3 calls to SuggestionHelper::tokenize()
- SuggestionHelper::insert in src/
SuggestionHelper.php - Add a suggestion.
- suggestion_surfer_submit in ./
suggestion.module - Custom submit function to add surfer suggestions.
- _suggestion_admin_submit_stopwords in ./
suggestion.admin.inc - Process stopwords.
File
- src/
SuggestionHelper.php, line 273 - Helper methods for the suggestion module.
Class
- SuggestionHelper
- Provides helper methods for suggestions.
Code
public static function tokenize($txt = '', $min = 4) {
$min--;
$regx = array(
'/[^a-z]+/s' => ' ',
'/\\b(\\w{1,' . $min . '})\\b/s' => '',
'/\\s\\s+/s' => ' ',
'/^\\s+|\\s+$/s' => '',
);
return preg_replace(array_keys($regx), array_values($regx), strtolower(trim($txt)));
}