# Help with Regex Expression Parsing

**URL:** https://discuss.codemirror.net/t/help-with-regex-expression-parsing/8030
**Category:** Lezer
**Created:** [March 23, 2024, 3:16am UTC](https://discuss.codemirror.net/t/help-with-regex-expression-parsing/8030 "2024-03-23T03:16:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jarrodek](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/jarrodek/32/4299_2.png) [@jarrodek](https://discuss.codemirror.net/u/jarrodek)
#### Post date: [March 23, 2024, 3:16am UTC](https://discuss.codemirror.net/t/help-with-regex-expression-parsing/8030/1 "2024-03-23T03:16:12Z")

</div>

I am trying to write a grammar file that would help me parse a Regex expression. I’ve already spent several evenings trying to do that. I was using the [https://lezer-playground.vercel.app/](https://lezer-playground.vercel.app/) playground, but it looks like the browser storage was cleared, so I can’t access my work anymore.  
Has anyone tried writing a regex grammar and would be willing to share? Or someone can offer help with writing one?

---

<div class="post-metadata">

### Author: ![AlexErrant](https://discuss.codemirror.net/user_avatar/discuss.codemirror.net/alexerrant/32/4287_2.png) [@AlexErrant](https://discuss.codemirror.net/u/AlexErrant)
#### Post date: [March 24, 2024, 5:29pm UTC](https://discuss.codemirror.net/t/help-with-regex-expression-parsing/8030/2 "2024-03-24T17:29:45Z")

</div>

I did a casual search for this a few days ago, but didn’t come up with much. The closest I saw was [Regexr](https://github.com/gskinner/regexr) which uses CodeMirror v5, but not Lezer. Regex101 uses CodeMirror too but isn’t open source. [Searching github for `regex.grammar`](https://github.com/search?q=path%3Aregex.grammar&type=code&ref=advsearch) and its variants didn’t yield much, and afaik gitlab doesn’t support file global search.

So I went with [what’s in Javascript](https://github.com/lezer-parser/javascript/blob/392c6115647c9e55c147ac2d702f75be127a7b2d/src/javascript.grammar#L683) and called it good. Some reasoning for it is given at the bottom of [this article](https://lezer.codemirror.net/examples/javascript/).

Note that grammar [is more interested in tokenization than correctness](https://github.com/lezer-parser/javascript/pull/31).

Please LMK if you find/build something better 🙂

Also FWIW I use [a clipboard manager](https://ditto-cp.sourceforge.io/) and have a habit of copying things, so even if my browser/computer crashes or whatever I won’t lose literally everything. I used to use a Chrome extension for form recovery, but it no longer works. Maybe I should try to find another; haven’t bothered.
