There are different ways to manipulate strings, look up parts of a string in various positions, and trim and replace strings. With each release of the JavaScript specification, more methods are added to make string search and manipulating easier than ever. So in this post I’ve collected some Javscript libraries that will make working with strings easy for developers.
Voca
The Voca library offers helpful functions to make string manipulations comfortable: change case, trim, pad, slugify, latinise, sprintf’y, truncate, escape and much more. The modular design allows to load the entire library, or individual functions to minimize the application builds. The library is fully tested, well documented and long-term supported.
String Format
JavaScript string formatting inspired by Python’s `str.format()`.
Fast Diff
This is a simplified import of the excellent diff-match-patch library by Neil Fraser into the Node.js environment. The match and patch parts are removed, as well as all the extra diff options. What remains is incredibly fast diffing between two strings.
Escape Html
This module exports a single function, escapeHtml, that is used to escape a string of content such that it can be interpolated in HTML content.
Strip Ansi
Strip ANSI escape codes from a string.
Case
String case utitility: convert, identify, flip, extend.
Filenamify
Convert a string to a valid safe filename.
Underscore.string
Javascript lacks complete string manipulation operations. This is an attempt to fill that gap. List of build-in methods can be found for example from Dive Into JavaScript. Originally started as an Underscore.js extension but is a full standalone library nowadays.
Slugify
Slugify a string.
Replace String
Replace all substring matches in a string.