# regexp-sourcemaps

> Similar to str.replace(regex, replace) but with sourcemap support

Latest version **1.0.1** (published 2015-04-30) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2015-04-30 |
| First published | 2015-04-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | L.systems SARL |
| Maintainers | even, l.systems |
| Keywords | regexp, sourcemaps, source-maps |

## Links

- npm: https://www.npmjs.com/package/regexp-sourcemaps
- Repository: https://bitbucket.org/lsystems/regexp-sourcemaps
- Issues: https://bitbucket.org/lsystems/regexp-sourcemaps/issues?status=new&status=open
- npm.io page: https://npm.io/package/regexp-sourcemaps

## Dependencies (1)

- [source-map](https://npm.io/package/source-map.md) ^0.4.2

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2015-04-30
- 1.0.0 — 2015-04-30

## README

## regexp-sourcemaps

Apply regexp replaces on a string & get the replaced string & sourcemap as a result.

### Usage

The package is rather easy to use:

```js
var Replacer = require('regexp-sourcemaps');

var someReplacer = new Replacer(/some(.*?)content/, 'my $1 result', 'regexpName');

var res = someReplacer.replace('somesupercontent', '/path/to/file');
// res.code === 'my super result'
// res.map contain the sourcemap to map the content properly
```

#### `Replacer(regexp, replace [, regexpName = null])`

`regexp`: the regexp to match in the content with or without capturing groups

`replace`: the pattern to replace the match with (everything matching is replaced), can contain referencies to capturing groups using `$nn` with:
- `$0` or `${0}`: the whole matching text
- `$n` or `${n}`: the `nth` capturing group (n ≥ 1)

`regexpName`: the name to give the regexp replace in the sourcemap, useful to have more info in the sourcemaps but optional

#### `Replacer.prototype.replace(content [, file = 'content'])`

`content`: the content on which to apply the transformation

`file`: the path to the file on which the transformation is applied to insert in the resulting sourcemap

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