..:: 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         831  0.4  0.4 1300716 71988 ?       Ssl  Jun15   7:43 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa         843  0.4  0.6 11696264 100812 ?     Ssl  Jun15   7:05 node /home/sasa/dex8/dex8-api/starter.js
sasa         858  0.3  0.3 1032720 60760 ?       Ssl  Jun15   5:38 node /home/sasa/regoch/regoch-www/server
sasa         867  0.3  0.3 1292724 58848 ?       Ssl  Jun15   5:31 node /home/sasa/dex8/dex8-panel/server/index.js
sasa         886  0.7  0.5 11835892 92996 ?      Ssl  Jun15  12:32 node /home/sasa/dex8/dex8-www/server/index.js
sasa         888  0.3  0.4 11789848 73780 ?      Ssl  Jun15   5:57 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa         904  0.6  0.4 1329612 81364 ?       Ssl  Jun15  10:05 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa         910  0.3  0.3 1295860 63616 ?       Ssl  Jun15   5:32 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa         969  0.3  0.3 1028404 55220 ?       Ssl  Jun15   5:26 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa         970  0.4  0.5 11808304 90120 ?      Ssl  Jun15   7:40 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa        1010  0.4  0.5 1138968 92200 ?       Ssl  Jun15   7:05 node /home/sasa/voovuu/voovuu-api/starter.js
sasa        1016  0.6  0.6 11814712 106536 ?     Ssl  Jun15   9:54 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1086  0.3  0.4 11595744 74836 ?      Ssl  Jun15   5:51 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa        1089  0.3  0.3 1099868 64728 ?       Ssl  Jun15   5:42 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1159  0.3  0.3 1099872 65152 ?       Ssl  Jun15   5:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1160  0.3  0.3 1099868 64008 ?       Ssl  Jun15   5:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1241  0.3  0.3 1101208 63180 ?       Ssl  Jun15   5:38 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1242  0.3  0.4 22278332 78804 ?      Ssl  Jun15   5:55 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1323  0.3  0.3 1099868 64008 ?       Ssl  Jun15   5:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1324  0.3  0.3 1099872 64088 ?       Ssl  Jun15   5:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1398  0.3  0.3 1099872 64012 ?       Ssl  Jun15   5:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1400  0.3  0.3 1100124 64676 ?       Ssl  Jun15   5:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1465  0.3  0.3 1099872 64976 ?       Ssl  Jun15   5:38 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1475  0.3  0.6 11810084 105844 ?     Ssl  Jun15   6:16 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
www-data   79384  0.0  0.0   2608   608 ?        S    05:41   0:00 sh -c ps -aux | grep node
www-data   79386  0.0  0.0   3304   736 ?        S    05:41   0:00 grep node