..:: 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        1194  0.5  0.4 1303240 80284 ?       Ssl  Oct24 267:43 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1200  0.9  0.8 11722608 139468 ?     Ssl  Oct24 467:09 node /home/sasa/dex8/dex8-api/starter.js
sasa        1207  0.4  0.4 1303884 72076 ?       Ssl  Oct24 219:50 node /home/sasa/regoch/regoch-www/server
sasa        1208  0.3  0.4 1304912 73320 ?       Ssl  Oct24 191:50 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.9  0.5 11801636 93372 ?      Ssl  Oct24 463:39 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.5 11810828 97352 ?      Ssl  Oct24 293:40 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1255  0.7  0.5 1330860 83620 ?       Ssl  Oct24 392:43 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1257  0.3  0.4 1300548 69300 ?       Ssl  Oct24 194:57 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1297724 66796 ?       Ssl  Oct24 192:16 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  3.2  2.7 12157396 453764 ?     Ssl  Oct24 1643:16 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1449  0.3  0.4 1169128 66840 ?       Ssl  Oct24 201:32 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1528  1.7  2.7 33114376 452444 ?     Ssl  Oct24 880:45 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1529  0.3  0.3 1100900 63960 ?       Ssl  Oct24 201:22 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1606  0.3  0.3 1100132 64292 ?       Ssl  Oct24 201:25 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1607  0.3  0.3 1100900 64832 ?       Ssl  Oct24 200:51 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1705  0.3  0.3 1101160 65452 ?       Ssl  Oct24 200:44 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1706  0.3  0.3 1101156 65176 ?       Ssl  Oct24 200:42 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1805  0.3  0.4 1167456 66288 ?       Ssl  Oct24 200:54 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1807  0.3  0.3 1100128 63068 ?       Ssl  Oct24 196:49 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1885  0.3  0.3 1099624 64056 ?       Ssl  Oct24 198:10 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1886  1.6  0.9 11858000 160624 ?     Ssl  Oct24 848:37 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     2628167  0.8  0.7 1169936 125704 ?      Ssl  Nov04 294:54 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11800780 91092 ?      Ssl  Nov06 208:37 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.4  0.5 11798408 83136 ?      Ssl  Nov06 136:14 node /home/sasa/@mikosoft/dodo-examples/server/index.js
www-data 3482459  0.0  0.0   2608   536 ?        S    01:56   0:00 sh -c ps -aux | grep node
www-data 3482461  0.0  0.0   3304   716 ?        S    01:56   0:00 grep node