New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

unpack-string

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

unpack-string

Unpacks the content found within a text, delimited by an opening char and a closing char, e.g., 'Can extract (only the content found here within these parentheses)'

  • 0.0.4
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
75K
increased by21.81%
Maintainers
1
Weekly downloads
 
Created
Source

unpack-string

Build Status

Unpacks the content found within a text, delimited by an opening char and a closing char, e.g., 'Can extract (only the content found here within these parentheses)'

Node.js and Browser ready.

Installation

npm install unpack-string

CLI

npm install unpack-string -g
npx unpack-string --help

Usage

It will extract the content found within the opening char and the closing char defined as parameters. If the parameter openingChar is not passed in, it will try to guess the first occurrence of some of these known chars '([{<', and, when the parameter closingChar is not passed in, it will try to guess some of these chars ')]}>', to match the openingChar.

Examples

const unpackString = require('unpack-string');

const str = 'Can extract (only the content [found {here} within] these parentheses)!!';

{
	const result = unpackString(str);

	// Guessing openingChar and closingChar. "()" in that case.
	// result === 'only the content [found {here} within] these parentheses'
}

{
	const openingChar = '[';
	const result = unpackString(str, openingChar);

	// Guessing closingChar: "]"
	// result === 'found {here} within'
}

{
	const openingChar = '{';
	const closingChar = ']';
	const result = unpackString(str, openingChar, closingChar);

	// Defining any openingChar and closingChar
	// result === 'here} within'
}

Keywords

FAQs

Package last updated on 09 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc