..:: 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 1329084 103668 ?      Ssl  Oct18  70:55 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1211  6.7  0.6 11700488 105972 ?     Ssl  Oct18 375:20 node /home/sasa/dex8/dex8-api/starter.js
sasa        1218  0.4  0.5 11798116 83536 ?      Ssl  Oct18  24:12 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1219  0.7  0.5 11803800 93852 ?      Ssl  Oct18  39:04 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1232  0.3  0.4 11795552 81044 ?      Ssl  Oct18  21:30 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1248  0.6  0.5 1331260 84768 ?       Ssl  Oct18  34:53 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1274  0.3  0.4 1298740 66500 ?       Ssl  Oct18  17:45 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1277  0.3  0.3 1297632 64308 ?       Ssl  Oct18  17:22 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1335  0.4  0.6 11834500 109252 ?     Ssl  Oct18  23:17 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa        1337  0.6  0.6 1154548 109176 ?      Ssl  Oct18  35:47 node /home/sasa/voovuu/voovuu-api/starter.js
sasa        1385  2.7  2.5 12123212 425304 ?     Ssl  Oct18 150:50 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1387  0.3  0.4 11796800 80712 ?      Ssl  Oct18  18:28 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa        1457  0.3  0.4 1101920 66380 ?       Ssl  Oct18  17:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1458  0.3  0.4 1102184 66468 ?       Ssl  Oct18  17:45 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1514  0.3  0.4 1102052 66136 ?       Ssl  Oct18  17:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1515  0.3  0.4 1101924 66188 ?       Ssl  Oct18  17:43 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1593  0.3  0.4 1101920 66332 ?       Ssl  Oct18  17:46 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1595  0.3  0.4 1101920 66308 ?       Ssl  Oct18  17:43 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1660  0.3  0.4 1102064 66880 ?       Ssl  Oct18  17:40 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1661  0.3  0.4 1101920 66744 ?       Ssl  Oct18  17:40 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1732  0.3  0.4 1101920 66504 ?       Ssl  Oct18  17:44 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1734  0.3  0.4 1101920 66524 ?       Ssl  Oct18  17:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1792  0.4  0.5 11802000 89036 ?      Ssl  Oct18  24:46 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa      367378  0.5  0.4 1327664 80244 ?       Ssl  Oct21   5:20 node /home/sasa/miko/miko-hr/api/starter.js
sasa      367471  1.2  0.9 11899152 159668 ?     Ssl  Oct21  12:39 node /home/sasa/miko/miko-hr/server/index.js
www-data  444148  0.0  0.0   2608   524 ?        S    09:21   0:00 sh -c ps -aux | grep node
www-data  444150  0.0  0.0   3304   652 ?        S    09:21   0:00 grep node