Giter Club home page Giter Club logo

Comments (4)

mbasso avatar mbasso commented on May 28, 2024

Hi @vaidsu,
I think that this is a fantastic idea, a converter that translates normal regex into natural regex might be useful for a lot of users and, unfortunately, at the moment there isn't one.
This means improving readability, as you said, and use a common language, avoiding integrations like this.
Do you have any idea about the implementation?
Please feel free to experiment and contribute! 😄

from natural-regex.

vaidsu avatar vaidsu commented on May 28, 2024

@mbasso thanks for motivation :) I am new to open source and have been prepping to do some good community service. Was watching for new innovative ideas and repos and found this will match my one of the first contributions.

Here is what I thought:

  • Use the lex way like you did to convert or connect the regular expression syntax to the natural expression.
  • The challenge is to see how far we can offer users. Are we going to parse the whole file and convert all the regular expression? Or let user use this as a part of their bundler and we provide as a plugin? Still I have to experiment few things.
  • Finally, the fun part is, we need to match regular expressions using regular expressions, to convert that regular expression into natural expressions - There are lot of hoops.
  • Trying to see if there is a better way to bring all the things together.

My main motive is to enforce people to see how readability increases when the code gets migrated.

Or in simple case, we can just offer a CLI or a service that converts a given expression into natural expression. May be that will be a good start? :)

I will come up with some fiddle and contact you.

from natural-regex.

mbasso avatar mbasso commented on May 28, 2024

Thank you for choosing this project 😄
I'm really happy that you like it.

Yeah, I think that this is a good starting point, I had the same idea.
We can use jison in the same way as I do for the conversion from natural to native regex, implementing the lexer and parser.
For example, we can add a NaturalRegex.reverse(code: string, flags: string or object) API to this library with a conditional import of the new parser (alternatively we can just create a new package) and then a --reverse param to natural-regex-cli.

The idea of parsing the whole file and convert all the regular expressions to natural-regex is awesome. Basically I think that, given a directory, we have to return all the given files with the natural-regex instead of the native ones, using the API that I wrote before. We can see if we can do this with babel for example. Do you know if it is possible in this way?

Regarding the plugin for the bundler, I think that this is a great idea if we want to do the opposite, convert natural-regex to native regex. This means no parsing at runtime, so, max performance. The bundle contains directly the native regexps while the original files contain our natural syntax. I think that this can be done with babel or with a plugin for webpack.

What do you think about that?

from natural-regex.

vaidsu avatar vaidsu commented on May 28, 2024

@mbasso I apologize for delay. I run a regular work and that drains me sometimes, but community service is what I do internally in my company. So wanted to raise hands to several other open source community.

I have pulled the code and already mocking up something. Will come up with something asap and send out a review.

Starting with the CLI is a good way to start that way we can probably help people learn the context and in the future you make it like real english and add more grammar we don't have to worry about adaptation. Hope I am close to what you have been thinking.

from natural-regex.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.