new-string-tools

1.0.1 • Public • Published
````markdown # StringMethods This package provides a collection of utility methods for manipulating strings. ## Installation ```bash npm install stringmethods ``` ```` ## Methods - **`replaceCount(str, oldSubstr, newSubstr, count)`** Replaces the first `count` occurrences of `oldSubstr` in `str` with `newSubstr`. **Usage:** ```javascript const StringMethods = require("stringmethods"); const str = "hello world hello world"; const newStr = StringMethods.replaceCount(str, "hello", "hi", 2); console.log(newStr); // Output: hi world hello world ``` - **`count(str, substr)`** Counts the number of occurrences of `substr` in `str`. **Usage:** ```javascript const StringMethods = require("stringmethods"); const str = "hello world hello world"; const count = StringMethods.count(str, "hello"); console.log(count); // Output: 2 ``` - **`isAlnum(str)`** Checks if `str` contains only alphanumeric characters (a-z, A-Z, 0-9). **Usage:** ```javascript const StringMethods = require("stringmethods"); const str1 = "hello123"; const str2 = "hello world"; console.log(StringMethods.isAlnum(str1)); // Output: true console.log(StringMethods.isAlnum(str2)); // Output: false ``` - **`isDigit(str)`** Checks if `str` contains only digits (0-9). **Usage:** ```javascript const StringMethods = require("stringmethods"); const str1 = "12345"; const str2 = "hello123"; console.log(StringMethods.isDigit(str1)); // Output: true console.log(StringMethods.isDigit(str2)); // Output: false ``` - **`isLower(str)`** Checks if `str` contains only lowercase letters (a-z). **Usage:** ```javascript const StringMethods = require("stringmethods"); const str1 = "hello"; const str2 = "Hello"; console.log(StringMethods.isLower(str1)); // Output: true console.log(StringMethods.isLower(str2)); // Output: false ``` - **`isUpper(str)`** Checks if `str` contains only uppercase letters (A-Z). **Usage:** ```javascript const StringMethods = require("stringmethods"); const str1 = "HELLO"; const str2 = "hello"; console.log(StringMethods.isUpper(str1)); // Output: true console.log(StringMethods.isUpper(str2)); // Output: false ``` - **`isSpace(str)`** Checks if `str` contains only whitespace characters. **Usage:** ```javascript const StringMethods = require("stringmethods"); const str1 = " "; const str2 = "hello"; console.log(StringMethods.isSpace(str1)); // Output: true console.log(StringMethods.isSpace(str2)); // Output: false ``` - **`capitalize(str)`** Capitalizes the first letter of `str` and converts the rest to lowercase. **Usage:** ```javascript const StringMethods = require("stringmethods"); const str = "hello world"; const capitalizedStr = StringMethods.capitalize(str); console.log(capitalizedStr); // Output: Hello world ``` - **`title(str)`** Capitalizes the first letter of each word in `str`. **Usage:** ```javascript const StringMethods = require("stringmethods"); const str = "hello world"; const titleStr = StringMethods.title(str); console.log(titleStr); // Output: Hello World ``` ``` ``` # s t r i n g m e t h o d s # s t r i n g m e t h o d s

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.1
    1
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.1
    1
  • 1.0.0
    1

Package Sidebar

Install

npm i new-string-tools

Weekly Downloads

2

Version

1.0.1

License

MIT

Unpacked Size

4.83 kB

Total Files

3

Last publish

Collaborators

  • sohumw