# regexp-replace

> base on RegExp#exec instead of String#replace

Latest version **1.0.2** (published 2022-02-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install regexp-replace
pnpm add regexp-replace
yarn add regexp-replace
bun add regexp-replace
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2022-02-21 |
| First published | 2022-02-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | SonOfMagic |
| Maintainers | icebreaker |
| Keywords | util, regexp-replace, regexp, replace |

## Links

- npm: https://www.npmjs.com/package/regexp-replace
- Repository: https://github.com/sonofmagic/regexp-replace
- Homepage: https://github.com/sonofmagic/regexp-replace#readme
- Issues: https://github.com/sonofmagic/regexp-replace/issues
- npm.io page: https://npm.io/package/regexp-replace

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2022-02-21
- 1.0.1 — 2022-02-21
- 1.0.0 — 2022-02-21

## README

# regexp-replace

> base on RegExp#exec instead of String#replace.

## Usage

```ts
const case = '<view class="p-[20px] -mt-2 mb-[-20px]">test case</view>'
const regex = /(?:class|className)=(?:["']\W+\s*(?:\w+)\()?["']([^"]+)['"]/gim
// remove class
replace(case, regex, (match, arr, idx, lastIdx, str) => {
  return ''
})

// sign
function replace(str: string, pattern: RegExp, replacement: string | ((match: string, arr: RegExpExecArray, index: number, lastIndex: number, string: string) => string)): string;

// params
// match -> RegExp match string
// arr -> RegExpExecArray
// index -> RegExpExecArray#index
// lastIndex -> RegExp#lastIndex
// string -> orignal string

```

More Usages see [here](https://github.com/sonofmagic/regexp-replace/blob/main/test/index.test.ts)

---
_Source: https://npm.io/package/regexp-replace · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
