..:: Source code - 035stringmethods_replace.js ::..

/**
 * String methods: replace
 * The replace() method returns a new string with some or all matches of a 
 * pattern replaced by a replacement.
 */
var str, x, xg, xi;

str = "simple example of simple string BIG big";

x = str.replace('simple', 'not simple'); //replace first match
xg = str.replace(/s\w+e/g, 'not simple'); //replace all matches
xi = str.replace(/BiG/i, 'SmaLL'); //case insensitive replacement


console.log(x); // not simple example of simple string BIG big
console.log(xg); // not simple example of not simple string BIG big
console.log(xi); // simple example of simple string SmaLL big
 

..:: NodeJS Console - 035stringmethods_replace.js ::..

$ node 035stringmethods_replace.js
not simple example of simple string BIG big
not simple example of not simple string BIG big
simple example of simple string SmaLL big
$ps -aux | grep node (list all node processes)
sasa         914  0.5  0.5 1306480 84808 ?       Ssl  Aug04 327:37 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa         935  0.7  0.8 11786840 132652 ?     Ssl  Aug04 484:38 node /home/sasa/dex8/dex8-api/starter.js
sasa         938  0.4  0.4 1307036 76776 ?       Ssl  Aug04 277:14 node /home/sasa/regoch/regoch-www/server
sasa         945  0.3  0.4 1303752 71464 ?       Ssl  Aug04 237:03 node /home/sasa/dex8/dex8-panel/server/index.js
sasa         947  0.7  0.6 11826356 113208 ?     Ssl  Aug04 484:15 node /home/sasa/dex8/dex8-www/server/index.js
sasa         966  0.5  0.6 11811024 99116 ?      Ssl  Aug04 365:06 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa         980  0.8  0.5 1330216 83376 ?       Ssl  Aug04 499:57 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa         997  0.3  0.4 1303104 72248 ?       Ssl  Aug04 239:33 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1021  0.3  0.4 1297920 65688 ?       Ssl  Aug04 236:03 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1065  0.6  0.6 11823516 100728 ?     Ssl  Aug04 402:26 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa        1074  0.6  0.6 1155716 104824 ?      Ssl  Aug04 392:36 node /home/sasa/voovuu/voovuu-api/starter.js
sasa        1136  0.7  1.1 11905812 182652 ?     Ssl  Aug04 455:59 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1148  0.4  0.4 11794644 78188 ?      Ssl  Aug04 261:24 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa        1197  0.3  0.3 1102188 65168 ?       Ssl  Aug04 244:08 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1199  0.3  0.4 22277756 77092 ?      Ssl  Aug04 247:56 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1308  0.3  0.3 1101664 65160 ?       Ssl  Aug04 243:21 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1325  0.3  0.3 1101408 64676 ?       Ssl  Aug04 243:15 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1393  0.8  0.8 22321292 141876 ?     Ssl  Aug04 498:55 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1395  0.3  0.3 1101676 64636 ?       Ssl  Aug04 244:20 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1489  0.3  0.3 1101152 64904 ?       Ssl  Aug04 244:17 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1496  0.3  0.4 1102432 67228 ?       Ssl  Aug04 243:04 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1607  0.3  0.3 1101408 64936 ?       Ssl  Aug04 243:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1608  0.3  0.4 1101920 65524 ?       Ssl  Aug04 242:22 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1686  1.1  0.8 11846976 147196 ?     Ssl  Aug04 742:56 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
www-data  751008  0.0  0.0   2608   524 ?        S    20:45   0:00 sh -c ps -aux | grep node
www-data  751010  0.0  0.0   3304   656 ?        S    20:45   0:00 grep node
sasa     1371685  0.4  0.5 11823568 96948 ?      Ssl  Aug16 198:25 node /home/sasa/mikosoft-info/solar-wind-energy/server/index.js
sasa     1460918  0.4  0.3 1300136 65224 ?       Ssl  Aug17 196:09 node /home/sasa/sites-nodejs/oxygen-free-copper/server.js