JSPM

unpack-string

0.0.4
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 88502
    • Score
      100M100P100Q156168F
    • License MIT

    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)'

    Package Exports

    • unpack-string

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (unpack-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    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'
    }