easy-replace

Replace strings with optional lookarounds, but without regexes

Usage no npm install needed!

<script type="module">
  import easyReplace from 'https://cdn.skypack.dev/easy-replace';
</script>

README

easy-replace

Replace strings with optional lookarounds, but without regexes

Install

npm i easy-replace

Quick Take

import { strict as assert } from "assert";
import er from "easy-replace";

assert.equal(
  er(
    "&nBsp; NBsp &nbSP NbsP;",
    {
      leftOutsideNot: "",
      leftOutside: "",
      leftMaybe: ["&", "&amp;"],
      searchFor: "nbsp",
      rightMaybe: ";",
      rightOutside: "",
      rightOutsideNot: "",
      i: {
        searchFor: true,
      },
    },
    "&nbsp;"
  ),
  "&nbsp; &nbsp; &nbsp; &nbsp;"
);

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