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

@thecyberlocal/strling

v2.5.3

Published

A next-generation object-oriented interface for regular expressions.

Downloads

9

Readme

STRling

🗺️ Project Overview

STRling is a next-generation production-grade syntax designed as a user interface for writing powerful regular expressions (RegEx) with an object-oriented approach and instructional error handling. STRling recognizes the cryptic nature of raw regular expression is challenging and susceptible to errors, which is why STRling keeps it as far from you as possible while maintaining the same power and flexibility. String validation should be simple and enjoyable, not a hassle. Best of all, STRling syntax is built upon the RegEx engine, making it fully compatible with all libraries that accept RegEx along with the traditional built-in RegEx methods.

🗝️ Key Features

  1. Beginner Friendly: You need ZERO knowledge of RegEx jargon to create powerful and clear-to-read patterns.
  2. Reliable Logic: STRling exclusively utilizes built-in libraries, making it a reliable package.
  3. Instructional Error Handling: Errors inevitably occur by drafting invalid patterns, so STRling explains to the developer exactly what was done wrong and how to correct it.
  4. Consistent and Readable: Make your projects clear and consistent by using STRling rather than the individual library string validators that each have their own syntax (Sqlite3, Sequelize, Postgres, WTForms... etc.).
  5. Multilingual Availability: STRling is not just a package, but a concept brought to you through multiple widely used languages.

These key features collectively emphasize and fortify the claim that STRling truly is a next-generation production-grade syntax for pattern handling.

🎯 Project Mission

Our mission is to make RegEx a distant and outdated syntax by abstracting the complexities of RegEx into a clean, readable, and powerful interface. We strive to simplify string operations and ensure that developers can focus on building their applications without the steep learning curve of traditional RegEx. The previous alternative to RegEx was to learn the string validation syntax specific to each user input library, but STRling aims to unify the disparate syntaxes found across various libraries and frameworks into one simple library using only built-in packages.

💾 Installation

Install STRling via npm:

npm install @thecyberlocal/strling

✨ STRling in action!

📑 STRling Documentation on GitHub

import { simply as s } from "@thecyberlocal/strling";

// Let's make a phone number pattern for the formats below:
// - (123) 456-7890
// - 123-456-7890
// - 123 456 7890
// - 1234567890

// Separator: either space or hyphen
const separator = s.inChars(" -");

// Optional area code part: 123 even if in parenthesis like (123)
const areaCode = s.merge(
  // notice we use merge since we don't want to name the group with parenthesis
  s.may("("), // Optional opening parenthesis
  s.group("area_code", s.digit(3)), // Exactly 3 digits and named for later reference
  s.may(")"), // Optional closing parenthesis
);

// Central part: 456
const centralPart = s.group("central_part", s.digit(3)); // Exactly 3 digits and named for later reference

// Last part: 7890
const lastPart = s.group("last_part", s.digit(4)); // Exactly 4 digits and named for later reference

// Combine all parts into the final phone number pattern
// Notice we don't name the whole pattern since we can already reference it
const phoneNumberPattern = s.merge(
  areaCode, // Area code part
  s.may(separator), // Optional separator after area code
  centralPart, // Central 3 digits
  s.may(separator), // Optional separator after central part
  lastPart, // Last part with hyphen and 4 digits
);

// Example usage
// Note: To make a pattern a RegEx string compatible with other engines use `toString(pattern)`.
const exampleText = "(123) 456-7890 and 123-456-7890";
const pattern = new RegExp(phoneNumberPattern.toString(), "g"); // Notice toString(pattern)
const matches = exampleText.matchAll(pattern);

for (const match of matches) {
  console.log("Full Match:", match[0]);
  console.log("Area Code:", match.groups.area_code);
  console.log("Central Part:", match.groups.central_part);
  console.log("Last Part:", match.groups.last_part);
  console.log();
}

// Output:
// Full Match: (123) 456-7890
// Area Code: 123
// Central Part: 456
// Last Part: 7890

// Full Match: 123-456-7890
// Area Code: 123
// Central Part: 456
// Last Part: 7890

Simplify your string validation and matching tasks with STRling, the all-in-one solution for developers who need a powerful yet user-friendly tool for working with strings. No longer write RegEx using complex jargon or the various syntaxes string validation specific to independent libraries. Download and start using STRling today!

🌎 Locations

STRling for Python

STRling for JavaScript

🌐 Socials

LinkedIn GitHub PyPI npm

💖 Support

If you find my content helpful or interesting, consider buying me a coffee. Every cup is greatly appreciated and fuels my work!

Buy Me a Coffee PayPal Venmo