protected function WordfilterProcessBase::prepareWordsForRegex in Wordfilter 8.2
Prepares the filter words for being used inside a regular expression.
Parameters
array $words: The (not yet) prepared filter words.
Return value
array The filter words, ready to be used inside a regular expression.
2 calls to WordfilterProcessBase::prepareWordsForRegex()
- DefaultWordfilterProcess::filterWords in src/
Plugin/ WordfilterProcess/ DefaultWordfilterProcess.php - Provides filtering of words by the given Wordfilter configuration.
- TokenWordfilterProcess::filterWords in src/
Plugin/ WordfilterProcess/ TokenWordfilterProcess.php - Provides filtering of words by the given Wordfilter configuration.
File
- src/
Plugin/ WordfilterProcessBase.php, line 23
Class
- WordfilterProcessBase
- Base class for Wordfilter Process plugins.
Namespace
Drupal\wordfilter\PluginCode
protected function prepareWordsForRegex(array $words) {
$prepared = [];
foreach ($words as $delta => $word) {
$prepared[$delta] = preg_quote(Xss::filterAdmin($word), '/');
if (strlen($prepared[$delta]) === strlen($word)) {
// Use word boundaries for 'naturally spoken' words.
$prepared[$delta] = '\\b' . $prepared[$delta] . '\\b';
}
}
return $prepared;
}