# replace-last

> JavaScript replaceLast function - Replaces last match for pattern in string with replacement

Latest version **1.2.6** (published 2018-03-31) · ISC license · 0 weekly downloads

## Install

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

## 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.2.6 |
| Published | 2018-03-31 |
| First published | 2017-10-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 4.0.0 |
| Dependencies | 0 |
| Unpacked size | 24.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | danday74 |
| Maintainers | danday74 |
| Keywords | replace last, replace, last, regex, string, lodash, underscore |

## Links

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

## 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.2.6 (latest) — 2018-03-31
- 1.2.5 — 2018-03-31
- 1.2.4 — 2018-03-31
- 1.2.3 — 2018-03-31
- 1.2.2 — 2018-03-30
- 1.2.1 — 2018-03-30
- 1.2.0 — 2018-03-19
- 1.1.0 — 2018-03-17
- 1.0.32 — 2017-11-10
- 1.0.31 — 2017-11-10
- 1.0.30 — 2017-11-10
- 1.0.29 — 2017-11-10
- 1.0.28 — 2017-11-10
- 1.0.27 — 2017-11-10
- 1.0.26 — 2017-11-10
- … 23 more at https://npm.io/package/replace-last/versions

## README

# replace-last

<br>[![linux](https://img.shields.io/travis/danday74/replace-last/master.svg?label=linux)](https://travis-ci.org/danday74/replace-last)
[![windows](https://img.shields.io/appveyor/ci/danday74/replace-last/master.svg?label=windows)](https://ci.appveyor.com/project/danday74/replace-last)
[![coverage](https://coveralls.io/repos/github/danday74/replace-last/badge.svg)](https://coveralls.io/github/danday74/replace-last)
<br>[![npm](https://img.shields.io/npm/v/replace-last.svg)](https://www.npmjs.com/package/replace-last)
[![dependencies](https://david-dm.org/danday74/replace-last/status.svg)](https://david-dm.org/danday74/replace-last)
[![downloads](https://img.shields.io/npm/dm/replace-last.svg)](https://www.npmjs.com/package/replace-last)
[![node](https://img.shields.io/node/v/replace-last.svg)](https://www.npmjs.com/package/replace-last)

**JavaScript replaceLast function - Replaces last match for pattern in string with replacement**



<br>

## Introduction

`npm install --save replace-last`

`replace-last` supports string and RegExp replacement. It works in Node code and browsers.

[View the code](js/replaceLast.js) | File size 1.7 KB | Fully unit tested | Zero dependency



<br>

## Node

```javascript 1.5
var replaceLast = require('replace-last');
replaceLast(str, pattern, replacement);
```

## Browser

```html
<script src="node_modules/replace-last/replaceLast.js"></script>
<script>
  replaceLast(str, pattern, replacement);
</script>
```

## Arguments

str='' (string): The string to modify.

pattern (RegExp|string): The pattern to replace.

replacement (string): The match replacement.

## Returns

(string): Returns the modified string.

## Examples

```javascript 1.5
replaceLast('hello hello hello', 'hello', 'bye');
// => 'hello hello bye';

replaceLast('hello hello hello', /he(ll)o/, 'rr');
// => 'hello hello herro';

replaceLast('hello hello hello', RegExp('.ell.'), 'bye');
// => 'hello hello bye'

replaceLast(777, 7, 8);
// => '778'
```



<br>

## Author says

God is the **last**?

> "Behold, I (Jesus) am coming quickly, and My reward is with Me, to give to each one according to the merit of his deeds (earthly works, faithfulness).
> I am the Alpha and the Omega, the First and the Last, the Beginning and the End [the Eternal One]."

[Revelation 22:12-13 AMP](https://www.bible.com/en-GB/bible/1588/REV.22.12-13.amp "Jesus loves you")

Jesus, King of Kings (**first**) put himself **last** - paying the death penalty for your wrongdoing - by willingly dying on the cross for you in your place.

He didn't do this because you loved Him. He did this even though you didn't love Him. He did this in the midst of all your hatred, your lust and worst of all, your apathy!

The nails never held him there, His love for you did! He commands men everywhere to repent and offers forgiveness for all them that believe!



<br><br><br>

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