..:: 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.2  0.6 1324940 99300 ?       Ssl  Oct18 333:59 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1211  7.9  0.7 11873652 115908 ?     Ssl  Oct18 2038:39 node /home/sasa/dex8/dex8-api/starter.js
sasa        1218  0.4  0.5 11803120 84312 ?      Ssl  Oct18 114:13 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1219  0.7  0.6 11808756 100404 ?     Ssl  Oct18 201:09 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1232  0.4  0.5 11806396 90632 ?      Ssl  Oct18 118:13 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1248  0.6  0.5 1331640 83520 ?       Ssl  Oct18 165:44 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1274  0.3  0.4 1301028 69096 ?       Ssl  Oct18  80:42 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1277  0.3  0.3 1298468 65176 ?       Ssl  Oct18  79:23 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1335  0.4  0.8 11856608 133908 ?     Ssl  Oct18 116:10 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa        1337  0.6  0.7 1193892 115372 ?      Ssl  Oct18 173:42 node /home/sasa/voovuu/voovuu-api/starter.js
sasa        1385  3.5  3.8 12334988 630832 ?     Ssl  Oct18 906:14 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1387  0.3  0.4 11797708 81280 ?      Ssl  Oct18  87:20 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa        1457  0.3  0.3 1099104 61392 ?       Ssl  Oct18  80:53 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1458  0.3  0.4 22281132 79944 ?      Ssl  Oct18  82:17 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1514  0.3  0.3 1099492 62596 ?       Ssl  Oct18  80:34 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1515  0.3  0.3 1099364 63076 ?       Ssl  Oct18  80:24 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1593  0.3  0.3 1099360 63584 ?       Ssl  Oct18  80:50 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1595  0.3  0.3 1099104 62516 ?       Ssl  Oct18  80:38 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1660  0.3  0.3 1099248 63136 ?       Ssl  Oct18  80:26 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1661  0.3  0.3 1099360 63376 ?       Ssl  Oct18  80:30 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1732  0.3  0.3 1099104 62888 ?       Ssl  Oct18  80:35 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1734  0.3  0.3 1099616 63380 ?       Ssl  Oct18  80:18 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1792  0.5  0.5 11805100 91404 ?      Ssl  Oct18 129:20 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa      367378  0.6  0.5 1331564 83784 ?       Ssl  Oct21 135:36 node /home/sasa/miko/miko-hr/api/starter.js
sasa      367471  1.2  1.0 11908680 178328 ?     Ssl  Oct21 258:30 node /home/sasa/miko/miko-hr/server/index.js
www-data 1949380  0.0  0.0   2608   596 ?        S    09:02   0:00 sh -c ps -aux | grep node
www-data 1949382  0.0  0.0   3304   712 ?        S    09:02   0:00 grep node