JSPM

  • Created
  • Published
  • Downloads 22867
  • Score
    100M100P100Q147762F
  • License MIT

Extract class (or id) name from a string

Package Exports

  • string-extract-class-names

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 (string-extract-class-names) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

string-extract-class-names

Extract class (or id) name from a string

Install

npm i string-extract-class-names

Quick Take

import { strict as assert } from "assert";
import extract from "string-extract-class-names";

// extracts classes
assert.deepEqual(extract("div.first-class.second-class"), [
  ".first-class",
  ".second-class",
]);

// and id's
assert.deepEqual(extract("div#brambles.gramples#croodles"), [
  "#brambles",
  ".gramples",
  "#croodles",
]);

// optionally, you can request ranges (see codsen.com/ranges/):
assert.deepEqual(extract("div.first-class.second-class", true), [
  [3, 15],
  [15, 28],
]);

Documentation

Please visit codsen.com for a full description of the API and examples.

Licence

MIT License

Copyright (c) 2010-2020 Roy Revelt and other contributors

ok codsen star