public static function SuggestionHelper::tokenize in Autocomplete Search Suggestions 8.2
Same name and namespace in other branches
- 8 src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::tokenize()
- 3.0.x src/SuggestionHelper.php \Drupal\suggestion\SuggestionHelper::tokenize()
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()
- SuggestionAdminForm::setStopwords in src/
Form/ SuggestionAdminForm.php - Process all the stopwords submitted.
- SuggestionHelper::insert in src/
SuggestionHelper.php - Add a suggestion.
- suggestion_surfer_submit in ./
suggestion.module - Custom submit function to add surfer suggestions.
File
- src/
SuggestionHelper.php, line 343
Class
- SuggestionHelper
- Provides helper methods for suggestions.
Namespace
Drupal\suggestionCode
public static function tokenize($txt = '', $min = 4) {
$min--;
$regx = [
'/[^\\w]+/su' => ' ',
'/\\b(\\w{1,' . $min . '})\\b/su' => '',
'/\\s\\s+/su' => ' ',
'/^\\s+|\\s+$/su' => '',
];
return preg_replace(array_keys($regx), array_values($regx), mb_strtolower(trim($txt)));
}