..:: 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         849  0.5  0.5 1317632 86412 ?       Ssl  Oct08 282:51 node /home/sasa/regoch/regoch-www/server
sasa         880  0.4  0.5 1319240 87380 ?       Ssl  Oct08 235:30 node /home/sasa/dex8/dex8-www/server/index.js
sasa         890  0.5  0.5 11797800 84948 ?      Ssl  Oct08 334:08 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa         903  0.7  0.5 1329652 82040 ?       Ssl  Oct08 430:34 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa         929  0.4  0.4 1300184 68964 ?       Ssl  Oct08 226:03 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa         943  0.4  0.4 1300808 66776 ?       Ssl  Oct08 233:10 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa         980  0.6  0.5 11805104 92236 ?      Ssl  Oct08 364:20 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa         981  0.7  0.6 1148036 104500 ?      Ssl  Oct08 394:43 node /home/sasa/voovuu/voovuu-api/starter.js
sasa        1039  0.9  1.4 11953364 245724 ?     Ssl  Oct08 554:47 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa     2044488  0.3  0.4 1298112 66856 ?       Ssl  Nov01  77:09 node /home/sasa/dex8/dex8-panel/server/index.js
sasa     2574087  0.3  0.4 11792920 76868 ?      Ssl  Nov08  41:44 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     2702010  0.4  0.6 22296952 99836 ?      Ssl  Nov10  34:52 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702011  0.3  0.4 1100276 66664 ?       Ssl  Nov10  31:02 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702018  0.3  0.3 1099884 64852 ?       Ssl  Nov10  31:05 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702019  0.3  0.4 1100516 66840 ?       Ssl  Nov10  31:03 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702046  0.9  0.7 22311780 124200 ?     Ssl  Nov10  84:08 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702047  0.3  0.3 1099492 64756 ?       Ssl  Nov10  31:20 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702088  0.3  0.4 1100008 67112 ?       Ssl  Nov10  31:05 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702089  0.3  0.4 1099752 66228 ?       Ssl  Nov10  31:01 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702137  0.3  0.4 1099864 65828 ?       Ssl  Nov10  30:52 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2702139  0.4  0.6 22297196 101444 ?     Ssl  Nov10  35:23 node /home/sasa/dex8/dex8-worker/starter.js
sasa     3097623  1.1  0.8 11718784 131476 ?     Ssl  Nov13  43:48 node /home/sasa/dex8/dex8-api/starter.js
www-data 3362087  0.0  0.0   2608   604 ?        S    07:29   0:00 sh -c node 035stringmethods_toString.js
www-data 3362088  0.0  0.1  89284 19376 ?        D    07:29   0:00 node 035stringmethods_toString.js
www-data 3362089  0.0  0.0   2608   604 ?        S    07:29   0:00 sh -c ps -aux | grep node
www-data 3362091  0.0  0.0   3304   660 ?        S    07:29   0:00 grep node