# Error when text entered in category select box contains invalid regex syntax

**URL:** https://meta.discourse.org/t/error-when-text-entered-in-category-select-box-contains-invalid-regex-syntax/27999
**Category:** Bug
**Created:** [2015年四月27日 15:03 UTC](https://meta.discourse.org/t/error-when-text-entered-in-category-select-box-contains-invalid-regex-syntax/27999 "2015-04-27T15:03:07Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [2015年四月27日 15:03 UTC](https://meta.discourse.org/t/error-when-text-entered-in-category-select-box-contains-invalid-regex-syntax/27999/1 "2015-04-27T15:03:07Z")

</div>

There’s a bug in `category-group.js.es6`:

[https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/category-group.js.es6#L16](https://github.com/discourse/discourse/blob/master/app/assets/javascripts/discourse/components/category-group.js.es6#L16)

Either, the userinput in `term` should be [escaped](http://stackoverflow.com/questions/3446170/escape-string-for-use-in-javascript-regex), or errors due to an invalid regex should be reported to the user.

To reproduce, go to your profile settings and type an asterisk in any of the category selection boxes, then check browser console and/or `/logs` for an “Uncaught SyntaxError: Invalid regular expression: /\*/: Nothing to repeat”.

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2015年四月29日 05:05 UTC](https://meta.discourse.org/t/error-when-text-entered-in-category-select-box-contains-invalid-regex-syntax/27999/2 "2015-04-29T05:05:41Z")

</div>

Sure… just escape it, seems like the original intention

---

<div class="post-metadata">

### Author: ![elberet](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elberet/32/122404_2.png) [@elberet](https://meta.discourse.org/u/elberet)
#### Post date: [2015年四月29日 10:22 UTC](https://meta.discourse.org/t/error-when-text-entered-in-category-select-box-contains-invalid-regex-syntax/27999/3 "2015-04-29T10:22:16Z")

</div>

[https://github.com/discourse/discourse/pull/3411](https://github.com/discourse/discourse/pull/3411)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [2015年四月30日 01:36 UTC](https://meta.discourse.org/t/error-when-text-entered-in-category-select-box-contains-invalid-regex-syntax/27999/4 "2015-04-30T01:36:37Z")

</div>


