# Which Regex Implementation Does Discourse Use?

**URL:** https://meta.discourse.org/t/which-regex-implementation-does-discourse-use/148935
**Category:** Development
**Created:** [April 23, 2020, 2:41am UTC](https://meta.discourse.org/t/which-regex-implementation-does-discourse-use/148935 "2020-04-23T02:41:03Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![007](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/007/32/175794_2.png) [@007](https://meta.discourse.org/u/007)
#### Post date: [April 23, 2020, 2:41am UTC](https://meta.discourse.org/t/which-regex-implementation-does-discourse-use/148935/1 "2020-04-23T02:41:03Z")

</div>

I’m working on some regex stuff for an import project and I ran into some issues. Just curious, which regex implementation does Discourse use?

---

<div class="post-metadata">

### Author: ![Dannii](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dannii/32/129087_2.png) [@Dannii](https://meta.discourse.org/u/Dannii)
#### Post date: [April 23, 2020, 3:15am UTC](https://meta.discourse.org/t/which-regex-implementation-does-discourse-use/148935/2 "2020-04-23T03:15:36Z")

</div>

I assume the built-in Ruby and Javascript ones.

---

<div class="post-metadata">

### Author: ![kneiser](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kneiser/32/178608_2.png) [@kneiser](https://meta.discourse.org/u/kneiser)
#### Post date: [April 23, 2020, 5:55am UTC](https://meta.discourse.org/t/which-regex-implementation-does-discourse-use/148935/3 "2020-04-23T05:55:57Z")

</div>

> [Class: Regexp (Ruby 2.6.5)](https://ruby-doc.org/core-2.6.5/Regexp.html)

When I run this in my Discourse repo:

```bash
bundle exec ruby --version

```

I get Ruby 2.6.5, so I’d refer to the Ruby docs at that version for specifics about their built-in RegEx engine 👍

---

<div class="post-metadata">

### Author: ![007](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/007/32/175794_2.png) [@007](https://meta.discourse.org/u/007)
#### Post date: [April 23, 2020, 6:40am UTC](https://meta.discourse.org/t/which-regex-implementation-does-discourse-use/148935/4 "2020-04-23T06:40:54Z")

</div>

Thanks! This is what I was looking for.

---

<div class="post-metadata">

### Author: ![kneiser](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/kneiser/32/178608_2.png) [@kneiser](https://meta.discourse.org/u/kneiser)
#### Post date: [April 28, 2020, 10:49pm UTC](https://meta.discourse.org/t/which-regex-implementation-does-discourse-use/148935/5 "2020-04-28T22:49:29Z")

</div>

In case anyone else stumbles upon this thread,  
I encourage you to check out:

> [@How to use Discourse regexes with watched words?](https://meta.discourse.org/t/could-someone-tell-me-about-discourse-regexes/61522/3):
>
> Reading that, I don’t see much about them except to see that they are Javascript regular expressions. (I would have assumed Ruby without that link.) So a Javascript reference would be in order. Which has internal links to specifications, if you want to go deeper.

I assumed wrongly just like @elijah over there: it’s actually Javascript-flavored.

Reach out to one of them if you’re still stuck 👍

---

<div class="post-metadata">

### Author: ![Dannii](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/dannii/32/129087_2.png) [@Dannii](https://meta.discourse.org/u/Dannii)
#### Post date: [April 29, 2020, 12:11am UTC](https://meta.discourse.org/t/which-regex-implementation-does-discourse-use/148935/6 "2020-04-29T00:11:30Z")

</div>

Well the JS code uses JS regexps, and the Ruby code uses Ruby regexps. I’m not sure about things like setting validations, those regexps may have to be written to be valid in both. Luckily it looks like the two languages have mostly consistent regexp flavours.
