Helper functions for working with strings.
In browser:
<script src="scripts/libs/ds-frontend/scripts/utils/string.js"></script>
<script>
ds.utils.string;
</script>
With browserify:
var string = require('ds-frontend/scripts/utils/string');
Name | Type | Description |
---|---|---|
source |
string | String to check up against |
needle |
string | String to check for |
Checks if strings start with needle
.
boolean
: Whether the source
starts with needle
.
ds.utils.string('this is a test').startsWith('this'); // => true
ds.utils.string('this is a test').startsWith('test'); // => false
Name | Type | Description |
---|---|---|
source |
string | String to remove html tags from |
Remove all html tags from string.
string
: The stripped string
ds.utils.string('<a href="#">this <i>is</i> a test</a>').stripTags();
// => 'this is a test'