# How should I add a new regex

**URL:** <https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505>\
**Category:** Uncategorized\
**Created:** [October 15, 2015, 8:11pm UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505 "2015-10-15T20:11:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarkBond](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/m/a9adbd/32.png) [@MarkBond](https://discuss.codemirror.net/u/MarkBond)\
**Post date:** [October 15, 2015, 8:11pm UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505/1 "2015-10-15T20:11:46Z")

</div>

So I figured out that I needed the javascript mode for my project but I also have a bunch of regular expressions from an older version of the project and my boss would like these to be implemented in the new project. My question is do i just add these regular expressions to the javascript.js file or do i need to create a new mode for these regular expressions?

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [October 15, 2015, 8:26pm UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505/2 "2015-10-15T20:26:10Z")

</div>

What do you mean by regular expressions? Are you using an extended JavaScript-based language that has extra syntax?

---

<div class="post-metadata">

**Author:** ![MarkBond](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/m/a9adbd/32.png) [@MarkBond](https://discuss.codemirror.net/u/MarkBond)\
**Post date:** [October 16, 2015, 11:37am UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505/3 "2015-10-16T11:37:19Z")

</div>

well this is what some of the old code looks like:

Regex oReg = new Regex("([\’][\)\(\s\w\_\_\?,.\+\-\$@½=:%#\<\>&/\\]_[\’])|" +  
// 1 Literal Text “([”][\)\(\s\w\_\_\?,.\+\-\$@½h=:%#\<\>&/\\]_["])|"

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [October 16, 2015, 11:50am UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505/4 "2015-10-16T11:50:34Z")

</div>

Sure, but adding a declaration for a new regexp variable to a mode doesn’t do anything. What I’m asking is how you are using the regexp.

---

<div class="post-metadata">

**Author:** ![MarkBond](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/m/a9adbd/32.png) [@MarkBond](https://discuss.codemirror.net/u/MarkBond)\
**Post date:** [October 16, 2015, 1:10pm UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505/5 "2015-10-16T13:10:40Z")

</div>

Sorry I just went over everything with my boss and what i said originally didn’t make sense. So what they want is to take a mode that is similar to the one we used to use for our old program and turn it into a new mode for our own language.

---

<div class="post-metadata">

**Author:** ![MarkBond](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/m/a9adbd/32.png) [@MarkBond](https://discuss.codemirror.net/u/MarkBond)\
**Post date:** [October 16, 2015, 4:02pm UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505/6 "2015-10-16T16:02:04Z")

</div>

Also just a silly question but how do you test whatever you put inside code mirror. I placed “console.log(/[0123456789]/.test(“in 1992”));” inside code mirror assuming it would pop up with true or false in the browser console but no such luck

---

<div class="post-metadata">

**Author:** ![marijn](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/marijn/32/136_2.png) [@marijn](https://discuss.codemirror.net/u/marijn)\
**Post date:** [October 19, 2015, 10:38am UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505/7 "2015-10-19T10:38:56Z")

</div>

You seem somewhat confused about that CodeMirror is. I think it would help to start by reading the [manual](http://codemirror.net/doc/manual.html) (it’s an editor, and only an editor).

---

<div class="post-metadata">

**Author:** ![MarkBond](https://discuss.codemirror.net/letter_avatar_proxy/v4/letter/m/a9adbd/32.png) [@MarkBond](https://discuss.codemirror.net/u/MarkBond)\
**Post date:** [October 19, 2015, 11:46am UTC](https://discuss.codemirror.net/t/how-should-i-add-a-new-regex/505/8 "2015-10-19T11:46:09Z")

</div>

To be honest I’m confused but not about codemirror specifically but what my boss wants me to do with it. To my understanding the older version of the program I’m working on used to have a editor where the user could type in some information that would be added to a table or create the table on that page and that tables information could be used for other things. Is codemirror able to help me with that? Also i read the manual before but ill go through it again and see if i missed something.
