Have ideas to improve npm?Join in the discussion! »

string-find-malformed

1.2.1 • Public • Published

string-find-malformed

Search for a malformed string. Think of Levenshtein distance but in search.

Install

npm i string-find-malformed

Quick Take

import { strict as assert } from "assert";
import strFindMalformed from "string-find-malformed";

// Below, we look for dodgy cases of `<!--`
const gathered = [];
strFindMalformed(
  "<div><!-something--></div>",
  "<!--",
  // your callback function:
  (obj) => {
    gathered.push(obj);
  },
  {
    maxDistance: 1, // Levenshtein distance
  }
);
assert.deepEqual(gathered, [
  {
    idxFrom: 5,
    idxTo: 8,
  },
]);

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

Install

npm i string-find-malformed

DownloadsWeekly Downloads

30

Version

1.2.1

License

MIT

Unpacked Size

98.6 kB

Total Files

10

Last publish

Collaborators

  • avatar