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

among

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

among

Find the substring / element among $start and $end argument.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

among

Travis

Find the substring / element between the $start and $end argument.

Developers often need to find a string between two elements. This package will simplify that task by abstract away the regex part.

Usage

$ npm i --save among
const among = require('among');

const str = 'The [quick] [brown] {{fox}} $jumps$ over the [lazy] {{dog}}';

let find = among('{{', '}}');

console.log(find(str));

find = among('[', ']', true);

console.log(find(str));

console.log(among('$', '$')(str));

Result:

[ 'fox', 'dog' ]
[ '[quick]', '[brown]', '[lazy]' ]
[ 'jumps' ]

Api

const find = among(string $start, string $end [, boolean $preserved]);

find(string $str)
  • $start is the first string to match

  • $end is the last string to match

  • $preserved is if the $start and $end strings should be preserved(optional)

  • $str the input string to search for elements

Tests

$ npm test

Contribution

Contributions are appreciated.

License

MIT-licensed. See LICENSE.

Keywords

FAQs

Package last updated on 17 May 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