Hello friends, I have a filter I use to block posts containing keywords in their titles. The problem is, they won’t work if the keyword appears at the very beginning of the post’s title. This is the filter:

lemmy.world##article.row:has-text(/\bKeyWord1\b|\bKeyWord2\b|\bKeyWord3/i)

I’ve tried ^KeyWord, and that doesn’t work either. And I’m now at the limits of my knowledge!

Any tips?

Cheers!

  • lad
    link
    fedilink
    English
    arrow-up
    2
    ·
    4 days ago

    Maybe it’s case-sensitivity? I’m not fluent in regexp to tell if /i in the end is meant to make search case-insensitive, but it looks to apply only to the third keyword

    • 58008@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      3 days ago

      Thanks for having a look at it!

      I think (99% guessing though) the opening forward slash - (/ - and the forward slash right before the i) is the beginning and end of the regex, with the parentheses being there just to group all of the stuff together, so the /i applies to everything after the (/. If I move the /i to the outside of the closing parenthesis, the whole filter turns red.

      Besides, the filter does seem to work as though that /i is correct; it filters keywords regardless of their case.

      Cheers!

  • Shadow@lemmy.ca
    link
    fedilink
    English
    arrow-up
    2
    ·
    4 days ago

    I don’t write ublock filters but I suspect your \b boundary isn’t matching for beginning of string.

    You could probably do [\b^] which should match either a boundary or beginning of string.

    • PoolloverNathan
      link
      fedilink
      English
      arrow-up
      5
      ·
      4 days ago

      [\b^] won’t work — I assume you meant something like (\b|^). That shouldn’t change anything either though, as \b is explicitly defined to match (^|$).