# \* wildcards in Watched Words (Censor) don't work

**URL:** <https://meta.discourse.org/t/wildcards-in-watched-words-censor-dont-work/77007>\
**Category:** Feature\
**Created:** [31 Diciembre, 2017 06:37 UTC](https://meta.discourse.org/t/wildcards-in-watched-words-censor-dont-work/77007 "2017-12-31T06:37:30Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![schungx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/schungx/32/70989_2.png) [@schungx](https://meta.discourse.org/u/schungx)\
**Post date:** [10 Enero, 2018 04:04 UTC](https://meta.discourse.org/t/wildcards-in-watched-words-censor-dont-work/77007/12 "2018-01-10T04:04:10Z")

</div>

I’m sorry, but not so fast.

Watched Words Censor now works for words with wildcards.

However, it _doesn’t_ work if `watched_words_regular_expression` is true.

I don’t think the censor function even considers it as regular expression at all.

Repo:

1. Settings \> watched words regular expression ==\> ON
2. Add `xyz*` to `Censor`
3. In compose window, type `xyz123`
4. See that it is censored as it is treating the `*` as a wildcard. If it is treated as a regular expression, `xyz*` should only match `xy` followed by a string of `zzzz`…

EDIT: The below is the culprit…

> <https://github.com/discourse/discourse/blob/ad62f1099cdb8782d20ca1296ea73467bc35fce7/app/assets/javascripts/pretty-text/censored-words.js.es6#L11-L13>

Notice that it is not even considering that the pattern may already be a regular expression.

Also,

> <https://github.com/discourse/discourse/blob/ad62f1099cdb8782d20ca1296ea73467bc35fce7/app/assets/javascripts/pretty-text/censored-words.js.es6#L23>

This is always assuming that the pattern is a word pattern and `\b` pairs are auto-wrapped onto it. If the pattern is a regular expression, obviously the `\b` pairs can be omitted because the user should put them in himself.

---

_[View the full topic](https://meta.discourse.org/t/wildcards-in-watched-words-censor-dont-work/77007)._
