npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

stripchar

v1.2.1

Published

Replace or Strip special character, alphabets and numerics from string or object - Javascipt - Node.js

Downloads

5,431

Readme

Description:


when you are working with Javascript | Node.js you can simply filter, strip or replace special characters,
alphabets and numerics from string or object by using this repository.

Installation:

npm install stripchar

Require:

var stripchar = require('stripchar').StripChar;

Usage:

// Strip all special characters EXCEPT underscore and alphanumeric

stripchar.RSExceptUnsAlpNum(input);

// Example

stripchar.RSExceptUnsAlpNum('ne@w_t#est_id_@12'); // new_test_id_12
// Replace all special characters with desired oone EXCEPT underscore and alphanumeric

stripchar.RSExceptUnsAlpNum(input, replacewith);

// Example

stripchar.RSExceptUnsAlpNum('new@test@id_12', '_'); // new_test_id_12
// Strip all special characters EXCEPT underscore and alphabet

stripchar.RSExceptUnsAlpha(input);

// Example

stripchar.RSExceptUnsAlpha('ne@w_t#est_id_12'); // new_test_id_12
// Replace all special characters with desired oone EXCEPT underscore and alphabet

stripchar.RSExceptUnsAlpha(input, replacewith);

// Example

stripchar.RSExceptUnsAlpha('new@test@id_12', '_'); // new_test_id_12
// Strip all special characters EXCEPT alphanumeric

stripchar.RSspecChar(input);

// Example

stripchar.RSspecChar('new@test@id'); // newtestid
// Replace all special characters with desired one EXCEPT alphanumeric

stripchar.RSspecChar(input, replacewith);

// Example

stripchar.RSspecChar('new@test@id', '_'); // new_test_id
// Strip everything EXCEPT numerics

stripchar.RSExceptNum(input);

// Example

stripchar.RSExceptNum('new@test@id_99'); // 99
// Replace everything with desired character EXCEPT numerics

stripchar.RSExceptNum(input, replacewith);

// Example

stripchar.RSExceptNum('new@test@id@99', '_'); // ____________99
// Strip everything EXCEPT alphabets

stripchar.RSExceptAlpha(input);

// Example

stripchar.RSExceptAlpha('new@test@id_99'); // newtestid
// Replace everything with desired character EXCEPT alphabets

stripchar.RSExceptAlpha(input, replacewith);

// Example

stripchar.RSExceptAlpha('new@test@id@99', '#'); // new#test#id###

Instructions:

Use the following format of either string or object or else you will get "false" in return.


// JSON format
var obj = {"col1": "id_1", "col2": "id_2", "col3": "id_3"};

// String format
var str = 'new_test_id';

when using replacing part of function do not not use the following as replacement otherwise it will be ignored automatically.


stripchar.RSExceptAlpha('new@test@id@99', 'null'); // return false

stripchar.RSExceptAlpha('new@test@id@99', 'undefined'); // return false

Run Test:

simply type the following command to run the test from CLI.

npm test

// OR

mocha

License

Stripchar is free software distributed under the terms of the MIT license.

Please support this project

Please support the project development, even a small donation can help grow this project!

Interested in some new feature?

Is there something new you like to see in this package ? Please contact me and i'll do my best to implement that in next releases.