Useful utilities for string searching and manipulation.
Have you had to split a string into a few parts based on a certain character or keyword? Or maybe place a word between symbols? Such operations are common when building an expression parser or simply working with text. Kolberg aims to make it easier by providing a simple, human-readable API.
- Lightweight
- Simple, human-readable API
- Written in TypeScript
$ npm install kolberg
import {get} from 'kolberg';
const result = get('the quick brown fox jumps over the lazy dog').between('the', 'dog')?.trim();
console.log(result); //=> 'lazy'
Type: string
String, which you want to search or manipulate.
Get the contents of a string before identifier. Returns a string
or undefined
.
Type: string | RegExp
The identifier, before which you want to receive the content.
Get the contents of a string after identifier. Returns a string
or undefined
.
Type: string | RegExp
The identifier, after which you want to receive the content.
Get the contents of a string between identifiers. Returns a string
or undefined
.
Type: string | RegExp
The identifier, from which you want to search.
Type: string | RegExp
The identifier, to which you want to search.
Type: string
String, which you want to search or manipulate.
Remove the contents of a string before identifier. Returns a string
or undefined
.
Type: string | RegExp
The identifier, before which you want to remove the content.
Remove the contents of a string after identifier. Returns a string
or undefined
.
Type: string | RegExp
The identifier, after which you want to remove the content.
Remove the contents of a string between identifiers. Returns a string
or undefined
.
Type: string | RegExp
The identifier, from which you want to search.
Type: string | RegExp
The identifier, to which you want to search.
Type: string
String, which you want to search or manipulate.
Replace the contents of a string before identifier. Returns a string
or undefined
.
Type: string | RegExp
The identifier, before which you want to replace the content.
Type: string
String, which you want to replace the content with.
Replace the contents of a string after identifier. Returns a string
or undefined
.
Type: string | RegExp
The identifier, after which you want to replace the content.
Type: string
String, which you want to replace the content with.
Replace the contents of a string between identifiers. Returns a string
or undefined
.
Type: string | RegExp
The identifier, from which you want to search.
Type: string | RegExp
The identifier, to which you want to search.
Type: string
String, which you want to replace the content with.
The name kolberg
comes from a Polish etnographer, folklorist, and composer active during the foreign Partitions of Poland - Henryk Oskar Kolberg.