..:: 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        1273  0.6  0.4 1303256 79600 ?       Ssl  Sep21 277:08 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1293  1.2  0.8 11722984 136272 ?     Ssl  Sep21 553:05 node /home/sasa/dex8/dex8-api/starter.js
sasa        1298  0.4  0.4 1309592 78396 ?       Ssl  Sep21 218:36 node /home/sasa/regoch/regoch-www/server
sasa        1309  0.4  0.4 1299340 67032 ?       Ssl  Sep21 193:05 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1320  0.8  0.6 11809840 102560 ?     Ssl  Sep21 404:24 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1329  0.6  0.5 11808740 94388 ?      Ssl  Sep21 288:12 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1340  0.8  0.5 1199580 83516 ?       Ssl  Sep21 388:30 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1357  0.4  0.4 1303220 72768 ?       Ssl  Sep21 194:58 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1381  0.4  0.4 1297336 66020 ?       Ssl  Sep21 192:13 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1417  0.6  0.5 11800048 88436 ?      Ssl  Sep21 313:26 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa        1477  0.4  0.4 11794680 77728 ?      Ssl  Sep21 211:33 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa        1966  1.1  0.8 11836832 135196 ?     Ssl  Sep21 516:37 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1026987  0.7  0.6 1154400 110796 ?      Ssl  Oct15  77:34 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     1041499  0.7  0.8 22320204 138484 ?     Rsl  Sep27 281:12 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041553  2.3  0.9 22340548 161752 ?     Ssl  Sep27 848:49 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041586  0.4  0.4 1167976 66940 ?       Ssl  Sep27 155:30 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041612  0.4  0.3 1166688 65456 ?       Ssl  Sep27 155:31 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041650  0.4  0.4 1168480 68056 ?       Ssl  Sep27 155:51 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041678  0.4  0.4 1167460 66776 ?       Ssl  Sep27 155:26 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041713  0.4  0.3 1166436 64736 ?       Ssl  Sep27 155:11 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041745  0.4  0.4 1166948 65640 ?       Ssl  Sep27 155:29 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041773  0.4  0.3 1099364 63148 ?       Ssl  Sep27 150:33 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1041811  0.4  0.3 1099104 63796 ?       Ssl  Sep27 151:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1617980  1.8  1.3 11950380 217376 ?     Ssl  Oct15 182:48 node /home/sasa/voovuu/voovuu-pub/server/index.js
www-data 2674550  0.0  0.0   2608   592 ?        S    14:51   0:00 sh -c ps -aux | grep node
www-data 2674552  0.0  0.0   3304   660 ?        S    14:51   0:00 grep node