..:: 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        1194  0.5  0.4 1303628 81648 ?       Ssl  Oct24 201:38 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1200  0.9  0.8 11721656 137784 ?     Ssl  Oct24 349:34 node /home/sasa/dex8/dex8-api/starter.js
sasa        1207  0.4  0.4 1305072 73548 ?       Ssl  Oct24 160:38 node /home/sasa/regoch/regoch-www/server
sasa        1208  0.3  0.4 1300560 68816 ?       Ssl  Oct24 144:26 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.9  0.6 11815368 102352 ?     Ssl  Oct24 358:51 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.6  0.5 11810572 96368 ?      Ssl  Oct24 219:20 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1255  0.7  0.5 1330064 82864 ?       Ssl  Oct24 284:32 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1257  0.4  0.4 1300548 68740 ?       Ssl  Oct24 146:34 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.3 1297184 65276 ?       Ssl  Oct24 144:46 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  3.2  2.7 12139892 442740 ?     Ssl  Oct24 1198:46 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1449  0.4  0.3 1166056 64156 ?       Ssl  Oct24 151:48 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1528  1.7  2.6 22610888 435676 ?     Ssl  Oct24 646:15 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1529  0.4  0.3 1101156 65388 ?       Ssl  Oct24 151:42 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1606  0.4  0.3 1101412 65196 ?       Ssl  Oct24 151:45 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1607  0.4  0.3 1101668 65088 ?       Ssl  Oct24 151:14 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1705  0.4  0.4 1101928 65780 ?       Ssl  Oct24 150:57 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1706  0.4  0.4 1101924 65756 ?       Ssl  Oct24 151:14 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1805  0.4  0.3 1101408 65372 ?       Ssl  Oct24 151:17 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1807  0.4  0.3 1100128 64160 ?       Ssl  Oct24 148:08 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1885  0.4  0.3 1099880 63920 ?       Ssl  Oct24 148:55 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1886  1.4  0.9 11846460 147596 ?     Ssl  Oct24 542:10 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
www-data 1179059  0.0  0.0   2608   592 ?        S    22:46   0:00 sh -c ps -aux | grep node
www-data 1179061  0.0  0.0   3304   716 ?        S    22:46   0:00 grep node
sasa     2628167  0.9  0.7 1162064 118064 ?      Ssl  Nov04 186:26 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11809720 92364 ?      Ssl  Nov06 120:54 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.4  0.5 11798408 83096 ?      Ssl  Nov06  81:18 node /home/sasa/@mikosoft/dodo-examples/server/index.js