..:: 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        1197  1.5  0.6 1326428 101528 ?      Ssl  Oct18 239:41 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1211  9.8  0.7 11710212 114824 ?     Ssl  Oct18 1536:07 node /home/sasa/dex8/dex8-api/starter.js
sasa        1218  0.4  0.5 11800816 84968 ?      Ssl  Oct18  68:23 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1219  0.7  0.6 11826508 103428 ?     Ssl  Oct18 118:51 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1232  0.4  0.5 11818172 89824 ?      Ssl  Oct18  68:51 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1248  0.6  0.5 1332664 84400 ?       Ssl  Oct18  99:22 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1274  0.3  0.4 1298324 65552 ?       Ssl  Oct18  48:41 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1277  0.3  0.4 1298372 65668 ?       Ssl  Oct18  47:43 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1335  0.4  0.7 11846880 124188 ?     Ssl  Oct18  68:48 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa        1337  0.6  0.7 1162020 115752 ?      Ssl  Oct18 100:35 node /home/sasa/voovuu/voovuu-api/starter.js
sasa        1385  2.8  2.5 12121416 416676 ?     Ssl  Oct18 452:45 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1387  0.3  0.4 11797312 81836 ?      Ssl  Oct18  51:36 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa        1457  0.3  0.3 1099360 63324 ?       Ssl  Oct18  48:48 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1458  0.3  0.4 22278316 77964 ?      Ssl  Oct18  49:07 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1514  0.3  0.3 1099748 64188 ?       Ssl  Oct18  48:33 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1515  0.3  0.3 1099620 64268 ?       Ssl  Oct18  48:30 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1593  0.3  0.3 1099360 63764 ?       Ssl  Oct18  48:43 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1595  0.3  0.3 1099104 62904 ?       Ssl  Oct18  48:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1660  0.3  0.3 1099248 63552 ?       Ssl  Oct18  48:28 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1661  0.3  0.3 1099360 63436 ?       Ssl  Oct18  48:32 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1732  0.3  0.3 1099360 63320 ?       Ssl  Oct18  48:31 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1734  0.3  0.3 1099360 63620 ?       Ssl  Oct18  48:23 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1792  0.4  0.5 11803512 89360 ?      Ssl  Oct18  69:59 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa      367378  0.6  0.5 1330404 82912 ?       Ssl  Oct21  67:07 node /home/sasa/miko/miko-hr/api/starter.js
sasa      367471  1.0  1.1 11903912 190820 ?     Ssl  Oct21 119:39 node /home/sasa/miko/miko-hr/server/index.js
www-data 1227058  0.0  0.0   2608   592 ?        S    08:46   0:00 sh -c ps -aux | grep node
www-data 1227060  0.0  0.0   3304   724 ?        S    08:46   0:00 grep node