Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
String helper methods that don't clobber the String prototype
JavaScript
tag: v0.1.0

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
test
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

Stringbean

Build Status

Stringbean is a collection of string helper methods that don't clobber the String prototype.

Installation

npm install stringbean

Usage

var stringbean = require('stringbean');

Methods

escapeHTML

Escapes HTML to entities

var someString = "<script>XSS Baby!</script>";
console.log(stringbean.escapeHTML(someString));

&lt;script&gt;XSS Baby!&lt;/script&gt

unescapeHTML

Unescapes escaped HTML

var someString = "&lt;script&gt;alert(&quot;oh hai&quot;);&lt;/script&gt;";
console.log(stringbean.escapeHTML(someString));

<script>alert("oh hai")</script>;

removeAlpha

Removes non alpha characters from a string

var someString = "ABC123def";
console.log(stringbean.removeAlpha(someString));

foo

removeNonAlphanumeric

Removes non alphanumeric characters from a string

var someString = "$£@@$%^foo(*&^%$£!@";
console.log(stringbean.removeNonAlphanumeric(someString));

foo

removeNonNumeric

Removes non alphanumeric characters from a string

var someString = "ABCefg123hij";
console.log(stringbean.removeNonNumeric(someString));

123

removeNumeric

Removes numeric characters from a string

var someString = "foo1a2b3cbar";
console.log(stringbean.removeNumeric(someString));

fooabcbar
Something went wrong with that request. Please try again.