Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

replace-last

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replace-last

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

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
39K
increased by17.4%
Maintainers
1
Weekly downloads
 
Created
Source

replace-last


linux windows coverage
npm dependencies downloads node

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


Introduction

npm install --save replace-last

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

View the code | File size 1.7 KB | Fully unit tested | Zero dependency


Node

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

Browser

<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

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(778, 8, 7);
// => '777'

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

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!




Keywords

FAQs

Package last updated on 19 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc