Javascript replace method

A few things about js replace method:

var anotherstr=str.replace(/<[^<>]+>/g, function(m) {
return m.replace( /__i__|%i%/g, n );});

First, str.replace does not change str itself, the result is saved in anotherstr.

Second, ^ in regex [] does not mean “beginning”, but “not”. “g” means global, for every match, the callback function is called with the matched string as the paramater m. The function returns a string used to replace the matched string. “|” in the regex // means “or”.

Did you like this?
Tip admin with Cryptocurrency

Donate Bitcoin to admin

Scan to Donate Bitcoin to admin
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to admin

Scan to Donate Bitcoin Cash to admin
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to admin

Scan to Donate Ethereum to admin
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to admin

Scan to Donate Litecoin to admin
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to admin

Scan to Donate Monero to admin
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to admin

Scan to Donate ZCash to admin
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply