Links
- github: jprichardson/string.js
- npm: string
- Browser
<script src="https://cdn.rawgit.com/jprichardson/string.js/master/lib/string.min.js"></script>
- Methods
between(left, right)
camelize()
capitalize()
dasherize()
humanize()
latinise()
underscore()
chompLeft(prefix)
chompRight(suffix)
collapseWhitespace()
contains(ss)
include(ss)
count(substring)
decodeHTMLEntities()
unescapeHTML()
wrapHTML()
slugify()
endsWith(ss)
escapeHTML()
ensureLeft(prefix)
ensureRight(suffix)
isAlpha()
isAlphaNumeric()
isEmpty()
isLower()
isNumeric()
isUpper()
left(n)
right(n)
length
lines()
pad(len, [char])
padLeft(len, [char])
padRight(len, [char])
parseCSV()
toCSV(options)
repeat(n)
replaceAll(ss, newstr)
s
toString()
setValue(value)
startsWith(prefix)
strip([string1],[string2],...)
stripLeft([chars])
stripRight([chars])
stripPunctuation()
stripTags([tag1],[tag2],...)
template(values, [open], [close])
times(n)
toBoolean() / toBool()
toFloat([precision])
toInt() / toInteger()
trim()
trimLeft()
trimRight()
truncate(length, [chars])
Notes
Get a JS string back from a wrapped string
// the .s property and the .toString() method give you back the JS backing strings.
var txt = "Hello";
assert(S(txt).s === txt);