1.0.2 • Published 1 year ago
sridhar-string-module v1.0.2
sridhar-string-module
- Some of the String Operations in Javascript
sridhar-string-module
- In this Module Provide some of the String Operation's. We can do Some type of String operations with the help of this module
Prerequisites
On Ubuntu/Debian:
sudo apt install npm nodejs
On Windows: npm install -g npm
Installation
Use Node to install from NPM Package Module
$ npm install <module name> --save
Usage of sridhar-string-module
Importing module with the help of creating node object
var sridhar-string-module = require('sridhar-string-module');
Find the Slices of the Given String
Usage
var slice_string = sridhar-math-module.slice_string(string,start_index,end_index);
console.log(slice_string);
Example
var slice_string = sridhar-math-module.slice_string("hello world",1,4);
console.log(slice_string);
Output
ello
Replace the Given String in previous String
Usage
var replace_string = sridhar-math-module.replace_string(string,start_index,end_index);
console.log(replace_string);
Example
var replace_string = sridhar-math-module.replace_string("hello world","Hello World");
console.log(replace_string);
Output
Hello World
Replace the Given String in All cases
Usage
var upper = sridhar-math-module.replace_all_string(string,start_index,end_index);
console.log(replace_all_string);
Example
var replace_all_string = sridhar-math-module.replace_all_string("hello world","Hello World");
console.log(replace_all_string);
Output
Hello World
Convert the Given String to Upper Case of the String
Usage
var upper = sridhar-math-module.upper(string);
console.log(upper);
Example
var upper = sridhar-math-module.upper("hello world");
console.log(upper);
Output
HELLO WORLD
Convert the Given String to Lower Case of the String
Usage
var lower = sridhar-math-module.lower(string);
console.log(lower);
Example
var lower = sridhar-math-module.lower("HELLO WORLD");
console.log(lower);
Output
hello world
Concatinate the Given Two String's
Usage
var concat_string = sridhar-math-module.concat_string(string1,string2);
console.log(concat_string);
Example
var concat_string = sridhar-math-module.concat_string("HELLO WORLD","I AM FROM INDIA");
console.log(concat_string);
Output
HELLO WORLD I AM FROM INDIA
Remove the all the white Spaces form the Given String
Usage
var trim = sridhar-math-module.trim(string);
console.log(trim);
Example
var trim = sridhar-math-module.trim("HELLO WORLD ");
console.log(trim);
Output
HELLOWORLD
Remove the End of the white Spaces form the Given String
Usage
var trimEnd = sridhar-math-module.trimEnd(string);
console.log(trimEnd);
Example
var trimEnd = sridhar-math-module.trimEnd("HELLO WORLD ");
console.log(trimEnd);
Output
HELLO WORLD
split the Given String into Multiple parts
Usage
var spilt = sridhar-math-module.spilt(string,requirment);
console.log(spilt);
Example
var spilt = sridhar-math-module.spilt("HELLO,WORLD",",");
console.log(spilt);
Output
"HELLO" "WORLD"
Get the specific Element in the Given String
Usage
var get_Index_element_string = sridhar-math-module.get_Index_element_string(string,index);
console.log(get_Index_element_string);
Example
var get_Index_element_string = sridhar-math-module.get_Index_element_string("hello world",3);
console.log(get_Index_element_string);
Output
l
"HELLO" "WORLD"
Chage the Capital in the first letter of the Given String
Usage
var capital_first_letter_each = sridhar-math-module.capital_first_letter_each(string);
console.log(capital_first_letter_each);
Example
var capital_first_letter_each = sridhar-math-module.capital_first_letter_each("hello world");
console.log(capital_first_letter_each);
Output
Hello World
Find the position of the given substring
Usage
var position_of_substring = sridhar-math-module.position_of_substring(string,substring);
console.log(position_of_substring);
Example
var position_of_substring = sridhar-math-module.position_of_substring("hello world",world);
console.log(position_of_substring);
Output
6