Answer the question
In order to leave comments, you need to log in
Finding stop words in a sentence using a pattern?
Hello!
Please tell me a regular expression that looks for certain words in the text.
Here's what was done:
$str = 'в начало элементов elements будет добавлен content, который может быть задан html-текстом, объектом jQuery или DOM объектом';
$pattern = ['elements', 'DOM'];
$matches = array();
$matchFound = preg_match_all(
"/\b(" . implode($pattern,"|") . ")\b/iu",
$str,
$matches
);
var_dump($matches[0])
Answer the question
In order to leave comments, you need to log in
search for words by a pattern, for example, by the word "elem * in", i.e. in this example, this pattern matches the word "elements"
'элем.*в'
.
for example, by the word "elem * in", i.e. in this example, this pattern matches the word "elements"Also suitable and "elements elements will be added", because * is any number of any characters.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question