DEV Community

Discussion on: Regular Expressions And Template Literals

Collapse
 
xowap profile image
Rémy 🤖

That's an interesting take, although I wonder how you could make comments more constructive. Right now you're simply describing things out loud, maybe there is a smarter story to tell?

Also I would be interested to get your opinion on this other take that I'm currently working on. Could also lead to something going in your direction.

GitHub logo Xowap / nsre

Non-String Regular Expressions

Non-String Regular Expressions

Build Status

NSRE (Non-String Regular Expressions) is a new spin at regular expressions It's really abstract, even compared to regular expressions as you know them but it's also pretty powerful for some uses.

Here's the twist: what if regular expressions could, instead of matching just character strings, match any sequence of anything?

from nsre import *

re = RegExp.from_ast(seq('hello, ') + (seq('foo') | seq('bar')))
assert re.match('hello, foo')
Enter fullscreen mode Exit fullscreen mode

The main goal here is matching NLU grammars when there is several possible interpretations of a single word, however there is a lot of other things that you could do. You just need to understand what NSRE is and apply it to something.

Note — This is inspired by this article from Russ Cox which explains how Thompson NFA work, except that I…

Collapse
 
rfornal profile image
bob.ts

Thanks for the comments.

I'll take a second look at my comments in the code. This was simply an experiment within JavaScript ... I'm not sure I'd be much help with your project. In fact, I'm pretty sure your project is out of my league.

Collapse
 
xowap profile image
Rémy 🤖

I think you are undervaluating what you did here, regex documentation and comprehension is a major issue in everyday developer life. That's a great insight you had and I think you can push this much further :)