Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

string-find-malformed

codsen187MIT4.0.20TypeScript support: included

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

character, find, fuzzy, levenshtein, lint, look, match, matches, search, similar, string, text, validate

readme

string-find-malformed

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

page on codsen.com page on npm page on github Downloads per month changelog MIT Licence

Install

This package is pure ESM. If you're not ready yet, install an older version of this program, 2.1.0 (npm i string-find-malformed@2.1.0).

npm i string-find-malformed

Quick Take

import { strict as assert } from "assert";

import { findMalformed } from "string-find-malformed";

// Below, we look for dodgy cases of `<!--`
const gathered = [];
findMalformed(
  "<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.

Contributing

To report bugs or request features or assistance, raise an issue on GitHub.

Licence

MIT License.

Copyright © 2010-2025 Roy Revelt and other contributors.

ok codsen star

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

4.0.0 (2022-12-01)

BREAKING CHANGES

  • Minimum supported Node version is v14.18; we're dropping v12 support

3.2.0 (2022-08-12)

Features

3.1.2 (2022-04-18)

Fixed

3.1.0 (2022-04-11)

Features

  • export defaults and version (1107244)

3.0.0 (2021-09-09)

Features

BREAKING CHANGES

  • programs now are in ES Modules and won't work with Common JS require()

2.1.0 (2021-05-24)

Features

  • config file based major bump blacklisting (e15f9bb)

2.0.15 (2021-04-11)

Reverts

  • Revert "chore: setup refresh" (23cf206)

2.0.1 (2021-01-28)

Fixed

  • add testStats to npmignore (f3c84e9)

2.0.0 (2021-01-23)

Features

  • rewrite in TS, start using named exports (ea15d44)

BREAKING CHANGES

  • previously: import findMalformed from ... - now import { findMalformed } from ...

1.2.0 (2020-11-28)

Accidental version bump during migration to SourceHut. Sorry about that.

1.1.5 (2020-04-26)

Fixed

  • harden the eslint rules set and make all unit tests pass again and rebase a little (52328ea)

1.1.0 (2020-03-16)

Fixed

  • correction to the algorithm (f1f4a00)

Features

  • init (8199031)
  • tweak the matching algorithm to jump to next character if not matched (f4b0e40)

1.0.0 (2020-03-01)

  • First public release