npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

regex-nlp

v1.0.10

Published

This app will form regex patterns by giving strings/dates/digits/special characters and also we can test the regex patterns using different methods.

Downloads

15

Readme

regex-nlp

Version Downloads

:point_right: regex-nlp Is an npm package where we can get the regex patterns by simply passing the text/number/any special characters or multiple texts/numbers/any special characters with some flags like case sensitive, global, and also in which format you need pattern(either in words, dates or in normal form).

:electric_plug: Installation

You can install it by running

Using npm

:arrow_right: npm install --save regex-nlp

Using yarn

:arrow_right: yarn add regex-nlp

:gear: Usage

import regexGenerator from "regex-nlp";

// if we need regular expression by giving strings/keywords then use this
regexGenerator.getRegexExpression(input, pattern, isCaseInSensitive, isGlobal);

// If we need to test our regex with multiple strings/keywords then use this 
regexGenerator.validateRegexEquation(keywords, regex, method, isReplaceString, isCase, isGlobaly);

Note: isCaseInSensitive and isGlobal values are false by default

:key: Examples

--Method 1: get regex expression--

let regexGenerator = require('../lib/pattern-generator');
let regexPattern;

// Note: isCaseInSensitive and isGlobal values are false by default

// If we need regex patterns related to **dates** then 
regexPattern = regexGenerator.getRegexExpression('12/12/2018', 'dates');
console.log(regexPattern); // output--> /[0-9]{2}[^a-z0-9]+[0-9]{2}[^a-z0-9]+[0-9]{2,4}/

// If we need regex pattern related to **words** then 
regexPattern = regexGenerator.getRegexExpression('regex', 'words', true, true);
console.log(regexPattern); // output--> /(regex)/ig

// If we need regex in **normal** pattern
regexPattern = regexGenerator.getRegexExpression('version 01', 'normal', true, true)
console.log(regexPattern); // output--> /[a-z0-9\s]/ig.
--Method 2: validate keywords using regex expression--

let regexGenerator = require('../lib/pattern-generator');
let res;

// Note: isCaseInSensitive and isGlobal values are false by default

res = regexGenerator.validateRegexEquation('some', '/[a-z]/i', 'test', false, true, true);
console.log(res); // output--> {keyword: 'some', result: true}

res = regexGenerator.validateRegexEquation('some', '/(some)/i', 'exec');
console.log(res); // output-->  {keyword: 'some', result: 'some'}

res = regexGenerator.validateRegexEquation('some', '/(some)/i', 'match');
console.log(res); // output-->  {keyword: 'some', result: 'some'}

res = regexGenerator.validateRegexEquation('some', '/(some)/ig', 'replace', '1234', true, true);
console.log(res); // output-->  {keyword: 'some', result: 1234}

res = regexGenerator.validateRegexEquation('this find find index of @', '/@/', 'search');
console.log(res); // output-->  {keyword: 'this find find index of @', result: 24}

:memo: Documentation

Method 1:

getRegexExpression(input, pattern, isCaseInSensitive, isGlobal)

Takes an input and forms regex patterns

Params

  • Any input : Takes any number of words , numbers or special characters or collection of keywords.

  • Boolean isCaseInSensitive : Flag which is tagged to regex pattern to handle case Sensitive cases.

  • Boolean isGlobal :flag which is tagged to attern to handle global cases.

  • String pattern : string where it is used to denote that the pattern should be in words, dates or in normal form.

Return

  • RegExp regular expression pattern

Method 2:

validateRegexEquation(keywords, regex, method, isReplaceString, isCase, isGlobaly)

Takes keyswords and regex as input and tests all the keywords and give back results

Params

  • Any keywords : Takes any number of words , numbers or special characters.

  • RegexExp regex : Takes regular expression.

  • String method: As of now validating only 5 methods like (test, match, exec, replace, search)

  • String isReplaceString: this variable is used when we choose replace method, giving the keyword to this variable will replace the string.

  • Boolean isCaseInSensitive : Flag which is tagged to regex pattern to handle case Sensitive cases.

  • Boolean isGlobal :flag which is tagged to attern to handle global cases.

Return

  • Array of objects with keyword and result

Need UI Interface for this package ?

Click on below link to experience the application

regexGenerator.com

:heart: Wohooo thats it !!!

:raising_hand_man: Maintainer

sra1bejugam

:scroll: License

MIT © sra1bejugam