..:: 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.4  0.5 1306980 85408 ?       Ssl  Aug04 121:31 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa         935  0.6  0.7 11786816 128596 ?     Ssl  Aug04 181:36 node /home/sasa/dex8/dex8-api/starter.js
sasa         938  0.3  0.4 1304976 73952 ?       Ssl  Aug04  96:31 node /home/sasa/regoch/regoch-www/server
sasa         945  0.3  0.4 1299400 65976 ?       Ssl  Aug04  88:07 node /home/sasa/dex8/dex8-panel/server/index.js
sasa         947  0.6  0.6 11811440 99060 ?      Ssl  Aug04 190:40 node /home/sasa/dex8/dex8-www/server/index.js
sasa         966  0.4  0.5 11809232 97044 ?      Ssl  Aug04 131:28 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa         980  0.6  0.5 1329944 82140 ?       Ssl  Aug04 168:35 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa         997  0.3  0.4 1300684 68184 ?       Ssl  Aug04  89:13 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1021  0.3  0.3 1297656 64880 ?       Ssl  Aug04  87:53 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1065  0.5  0.5 11803028 91884 ?      Ssl  Aug04 142:24 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa        1074  0.5  0.6 1147628 102988 ?      Ssl  Aug04 144:00 node /home/sasa/voovuu/voovuu-api/starter.js
sasa        1136  0.6  1.0 11882356 165884 ?     Ssl  Aug04 173:49 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1148  0.3  0.4 11794388 77688 ?      Ssl  Aug04  95:29 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa        1197  0.3  0.3 1099116 63328 ?       Ssl  Aug04  90:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1199  0.3  0.3 1099872 63856 ?       Ssl  Aug04  90:15 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1308  0.3  0.3 1099616 63900 ?       Ssl  Aug04  90:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1325  0.3  0.3 1099360 64188 ?       Ssl  Aug04  90:36 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1393  0.6  0.7 22314068 130780 ?     Ssl  Aug04 184:43 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1395  0.3  0.3 1099884 64540 ?       Ssl  Aug04  90:51 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1489  0.3  0.3 1099360 63680 ?       Ssl  Aug04  90:57 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1496  0.3  0.3 1100128 64572 ?       Ssl  Aug04  90:21 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1607  0.3  0.3 1099104 63888 ?       Ssl  Aug04  90:35 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1608  0.3  0.3 1099616 64140 ?       Ssl  Aug04  90:04 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1686  0.5  0.6 11813248 110616 ?     Ssl  Aug04 144:35 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1371685  0.3  0.5 11799572 85504 ?      Ssl  Aug16  36:06 node /home/sasa/mikosoft-info/solar-wind-energy/server/index.js
sasa     1460918  0.3  0.3 1298600 63680 ?       Ssl  Aug17  32:07 node /home/sasa/sites-nodejs/oxygen-free-copper/server.js
www-data 2152746  0.0  0.0   2608   588 ?        S    21:22   0:00 sh -c ps -aux | grep node
www-data 2152748  0.0  0.0   3304   720 ?        S    21:22   0:00 grep node