1.8.3 • Published 4 years ago

substring-methods v1.8.3

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

npm.io npm.io npm.io

Substring Methods

A collection of methods related to substrings in JavaScript

Usage

npm install substring-methods

In your code

const { firstLetter } = require('substring-methods');

console.log(firstLetter("Test string"));

Methods

firstLetter

Get the first letter of a string

const s = firstLetter("Hello"); 
// returns "H"

lastLetter

Get the last letter of a string

const s = lastLetter("Hello"); 
// returns "o"

randomLetter

Get a random letter of a string

const s = randomLetter("Hello"); 

numberOfOccurrences

Count the number of times a substring occurs inside a string

const s = numberOfOccurrences("The heater he ordered for them was hefty", "he");
// returns 5

allPossibleSubstrings

Gets all possible contiguous substrings inside a string

const s = allPossibleSubstrings("cat");
// returns [ 'c', 'a', 't', 'ca', 'at', 'cat' ]

allSubstringsOfLength

Gets all possible contiguous substrings of a given length inside a string

const s = allSubstringsOfLength("word", 2);
// returns [ 'wo', 'or', 'rd' ]
1.7.3

4 years ago

1.6.3

4 years ago

1.5.3

4 years ago

1.4.3

4 years ago

1.8.3

4 years ago

1.3.3

4 years ago

1.3.2

4 years ago

1.2.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago