Filter by specific word count via RegEx

I’m trying to filter out HTML that does not include at least two incidents of a specific word (in this case ‘Dylan’) and I got this recommended regex expression from ChatGPT:

(?i)(?:.*\bDylan\b){2}

I’m using it in filters with Matches Pattern - except it does not work. If I get rid of the Regex and just filter for the word ‘Dylan’ it works, but there are so many articles that name-check Dylan that I need to filter down for those that use the word at least twice.

Is that RegEx wrong? Is there some other way to do this? I’m doing an HTTP pull of the HTML (which works fine) and using a Text Parser to strip the HTML (which also works) and I’ve tried using the filter against the HTTP raw data or the post HTML data, neither works reliably even regardless of the word count.

Any suggestions appreciated.

You can use

{{lower(7.text)}}

Matches pattern

\bdylan\b.+\bdylan\b

Proof: https://regex101.com/r/qJd2CY/1

For more information, see Text Parser in the Make Help Center for more information about regex patterns:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Thanks. So the two versions of \bdylan\ are making sure there are at least two occurrences of that word?

Yes.

1. If anyone has a new question in the future, please start a new thread. This makes it easier for others with the same problem to search for the answers to specific questions, and you are more likely to receive help since newer questions are monitored closely.

2. The Make Community guidelines encourages users to try to mark helpful replies as solutions to help keep the Community organized.

This marks the topic as solved, so that:

  • others can save time when catching up with the latest activity here, and
  • allows others to quickly jump to the solution if they come across the same problem

To do this, simply click the checkbox at the bottom of the post that answers your question:
Screenshot_2023-10-04_161049

3. Don’t forget to like and bookmark this topic so you can get back to it easily in future!

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.