# Censored pattern

**URL:** <https://meta.discourse.org/t/censored-pattern/66912>\
**Category:** Bug\
**Created:** [July 27, 2017, 9:40am UTC](https://meta.discourse.org/t/censored-pattern/66912 "2017-07-27T09:40:35Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)\
**Post date:** [August 31, 2017, 4:16am UTC](https://meta.discourse.org/t/censored-pattern/66912/7 "2017-08-31T04:16:03Z")

</div>

> [@sam](#):
>
> Anyone have any ideas on how to rewrite:
> 
> censorRegexp = new RegExp(“(\b(?:(hello)|(Здравствуйте))\b)(?![^\(]\*\))”, “ig”);
> 
> So it does not use \b which is unsupported Russian.

In Ruby, I’d do something like:

```ruby
censor_list.split('|').map!{|w| w.gsub(/^\w+$/, "\b#{w}\b") }.join('|')

```

So that word boundaries are automatically applied only to things that look like words.

```plaintext
irb(main):011:0> "aaa|Здравствуйте|bbb".split('|').map!{|w| w.gsub(/^\w+$/, "\b#{w}\b") }.join('|')
=> "\baaa\b|Здравствуйте|\bbbb\b"
irb(main):012:0> 

```

---

_[View the full topic](https://meta.discourse.org/t/censored-pattern/66912)._
