regcode
TypeScript icon, indicating that this package has built-in type declarations

0.0.11 • Public • Published


Regcode logo

Create regular expressions easily with code

npm

DocsDemoFeaturesExamplesAPILicense


screenshot

✔️ Features

  • Create Regular Expressions with code
  • English-like syntax that is easy to read
  • Easy to learn, easy to read
  • Simple API
  • Convert to Regex or match directly to a string
  • Get started in minutes
  • No need to learn Regex to create an expression

📋 Examples

These are some basic examples, there are many more examples over at our docs page. You can also try it interactively here.

// use values
const code = "[character]"
const regex = "/[A-Za-z\u00C0-\u017F]/"

// use logic
const code = "[character]{oneOrMore}][or][number]"
const regex = "/(?:[A-Za-z\u00C0-\u017F]+|\d)/"

// use methods
const code = "normal(H[or]hello) [whitespace] [character]{oneOrMore}"
const regex = "/(?:H|h)ello\s[A-Za-z\u00C0-\u017F]+/"

☁️ API Example

Install Regcode with NPM or Yarn.

# npm
npm install regcode --save

# yarn
yarn add regcode

Simply create the class and begin using it.

import { RegCode } from "regcode";

const regCode = new RegCode();
const code = "hasBefore(https://) normal(www.) [character]{any} normal(.com)[or]normal(.net)";
const sentenceToMatch = "The URL is https://www.regcodejs.com, here you go!";

// look for matches
const match = regCode.match(code, sentenceToMatch); // ["www.regcodejs.com"]

// or convert to regex and match the normal way
const regex = regCode.convert(code);
const match = sentenceToMatch.match(regex);         // ["www.regcodejs.com"]

License

MIT

Package Sidebar

Install

npm i regcode

Weekly Downloads

4

Version

0.0.11

License

MIT

Unpacked Size

66.4 kB

Total Files

56

Last publish

Collaborators

  • banjoanton