Giter VIP home page Giter VIP logo

natural-regex's Introduction

natural-regex

Build Status npm version npm downloads Join the chat at https://gitter.im/mbasso/natural-regex

Create regex from natural language


Attention - This project isn't completed yet. There might be breaking changes until version 1.0.0. Feel free to contribute, see TODO to get started.


natural-regex is a parser that allows you to write regular expressions in natural language. This means that you can write self documentating regex using a simpler syntax that can be undestood by anyone. No more pain with validations and other stuff.

Installation

You can install natural-regex using npm:

npm install --save natural-regex

If you aren't using npm in your project, you can include NaturalRegex using UMD build in the dist folder with <script> tag.

Usage

Once you have installed natural-regex, supposing a CommonJS environment, you can import and immediately use it:

import NaturalRegex from 'natural-regex';
// validate string
const dateAndEmail = NaturalRegex.from('starts with dd/MM/yyyy, space, minus, space and then email, end.');
dateAndEmail.test('06/07/2016 - [email protected]'); // this evaluates true
dateAndEmail.test('Foo Bar foo@bar'); // this evaluates false

// replace in string
NaturalRegex.replace({
  string: '06/07/2014 - [email protected]',
  match: 'yyyy',
  replace: '2016',
});
// this returns '06/07/2016 - [email protected]'

NaturalRegex also includes a command line tool, check this for more information.

Documentation

Visit the Wiki for the full documentation.

Examples

Examples can be found here

Change Log

This project adheres to Semantic Versioning.
Every release, along with the migration instructions, is documented on the Github Releases page.

Authors

Matteo Basso

Copyright and License

Copyright (c) 2016, Matteo Basso.

natural-regex source code is licensed under the MIT License.

natural-regex's People

Contributors

mbasso avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

natural-regex's Issues

Conversion from regular regex to natural regex

General Information

  • Bug
  • Improvement
  • Feature
  • Other

Description

Most of the users are used to writing regex and due to its legacy there is lot of code already written in regex syntax (be it any language of choice). With that said, it will be great if we can have a converter that can convert from regex expression to natural regex, that way a library of regex can be used and an index can be generated which can then be used across the code. Kind of similar to webpack's index within the final bundled file (if I am clear with the comparison).

That way the existing code can be converted into Natural regex improving its readability (which I believe is one of the important motivations of this project). While that is done, users might tend to move towards natural regex.

I will try to experiment a converter.

If there is already one, please comment.

Hoping if I can contribute.

Is there a way to express negation

General Information

  • Bug
  • Improvement
  • Feature
  • Other

Description
Is there a way to express negation --> not end with js or similar?
(Add images if possible)

Steps to reproduce

(Add link to a demo on https://jsfiddle.net or similar if possible)

Versions

  • natural-regex:
  • Browser:

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.