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 🙏

© 2026 – Pkg Stats / Ryan Hefner

regex-toolkit

v0.0.3

Published

RegexToolkit adalah sebuah alat sederhana untuk mempermudah penggunaan *regular expressions* (regex) di JavaScripti

Readme

RegexToolkit

RegexToolkit alat sederhana untuk mempermudah penggunaan regular expressions (regex) di JavaScript

Alat ini dirancang agar fleksibel dan ramah pengguna, memungkinkan pencocokan teks literal (escape otomatis) atau menggunakan regex mentah sesuai kebutuhan.

Fitur Utama

Escape Otomatis

  • Semua pola default di-escape untuk mencocokkan teks literal, sehingga pengguna tidak perlu memahami karakter khusus regex.

Dukungan Regex Mentah

  • Dengan opsi useRawPattern, pengguna dapat menggunakan pola regex mentah.

Dukungan Semua Tipe Data

  • Semua tipe data akan dikonversi ke string sebelum diproses.

API Sederhana

  • Mendukung operasi seperti test, match, replace, split, dan extractGroups.

Instalasi

npm install regex-toolkit

Penggunaan

1. Import Library

ESM
import { RegexToolkit } from 'regex-toolkit'
CommonJS
const { RegexToolkit } = require('regex-toolkit')

2. Membuat Instance Baru

Buat instance baru dengan pola regex dan flag opsional.

const regex = new RegexToolkit('Halo', 'g') // Default escape

2. Menggunakan Pola Regex

Pola default di-escape untuk mencocokkan teks literal.

console.log(regex.test('Halo Halo!')) // true
console.log(regex.match('Halo Halo!')) // ['Halo', 'Halo']

3. Menggunakan Regex Mentah

Jika ingin menggunakan pola regex mentah.

regex.updatePattern('Halo\\.', 'g', true) // Gunakan pola mentah
console.log(regex.match('Halo. Halo.')) // ['Halo.', 'Halo.']

4. Ganti Teks Menggunakan Pola

Mengganti teks yang cocok dengan regex.

regex.updatePattern('Halo') // Escape otomatis
console.log(regex.replace('Halo, Apa kabar?', 'Hi')) // Hi, Apa kabar?

5. Pisahkan String

Pisahkan string berdasarkan pola regex.

regex.updatePattern(',') // Escape otomatis
console.log(regex.split('1,2,3,4')) // ['1', '2', '3', '4']

6. Ekstrak Grup dari Hasil

Ekstrak grup yang cocok dari pola regex.

regex.updatePattern('(Halo) (Dunia)', '', true) // Regex mentah
console.log(regex.extractGroups('Halo Dunia')) // ['Halo', 'Dunia']

7. Cek Detail Pola

Cek detail pola regex saat ini.

console.log(regex.getDetails())
/* Output:
{
  pattern: 'Halo',
  flags: 'g',
  useRawPattern: false
}
*/

API

constructor

constructor((pattern = ''), (flags = ''), (useRawPattern = false))

  • pattern (string): Pola regex awal. Default adalah string kosong.
  • flags (string): Flag regex opsional seperti g, i, dll.
  • useRawPattern (boolean): Jika true, menggunakan regex mentah; jika false, pola akan di-escape.

method

updatePattern(pattern, flags = '', useRawPattern = false)

Mengubah pola regex dengan opsi untuk menggunakan regex mentah.

  • pattern (string): Pola regex baru.
  • flags (string): Flag regex baru.
  • useRawPattern (boolean): Gunakan regex mentah jika true.

test(input)

Menguji apakah input cocok dengan pola regex.

  • input (any): Teks atau data yang akan diuji.

  • Return:

    • (boolean) Hasil pengujian.

match(input)

Mencocokkan semua hasil sesuai dengan pola regex.

  • input (any): Teks atau data yang akan dicocokkan.

  • Return:

    • (array|null) Array hasil pencocokan.

replace(input, replacement)

Mengganti teks yang cocok dengan pola regex.

  • input (any): Teks yang akan diubah.

  • replacement (string): Pengganti teks.

  • Return:

    • (string) Hasil penggantian.

split(input)

Memisahkan string berdasarkan pola regex.

  • input (any): Teks yang akan dipisahkan.

  • Return:

    • (array) Array hasil pemisahan.

extractGroups(input)

Mengekstrak grup dari hasil pencocokan.

  • input (any): Teks yang akan diproses.

  • Return:

    • (array) Array grup yang cocok.

getDetails()

Mendapatkan detail pola regex saat ini.

  • Return:

    • (object) Objek dengan properti:
    • pattern (string): Pola regex.
    • flags (string): Flag regex.
    • useRawPattern (boolean): Apakah menggunakan regex mentah.

escape(text)

Metode statis untuk melindungi teks literal (escape karakter regex).

  • text (string): Teks yang akan di-escape.

  • Return:

    • (string) Teks yang sudah di-escape.