..:: 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.5 1304708 82468 ?       Ssl  Oct24 248:43 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1200  0.9  0.8 11722864 139464 ?     Ssl  Oct24 441:03 node /home/sasa/dex8/dex8-api/starter.js
sasa        1207  0.4  0.4 1306172 74356 ?       Ssl  Oct24 202:09 node /home/sasa/regoch/regoch-www/server
sasa        1208  0.3  0.4 1304912 72484 ?       Ssl  Oct24 177:50 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.9  0.6 11823908 101304 ?     Ssl  Oct24 433:12 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.5 11806476 93108 ?      Ssl  Oct24 271:53 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1255  0.7  0.5 1330472 82948 ?       Ssl  Oct24 360:36 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1257  0.3  0.4 1300548 69444 ?       Ssl  Oct24 180:44 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1297912 67692 ?       Ssl  Oct24 178:18 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  3.1  2.6 12145268 440500 ?     Ssl  Oct24 1484:07 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1449  0.4  0.3 1167336 65472 ?       Ssl  Oct24 186:49 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1528  1.8  2.6 22626244 437132 ?     Ssl  Oct24 856:45 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1529  0.3  0.3 1099876 63452 ?       Ssl  Oct24 186:44 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1606  0.3  0.3 1099364 63636 ?       Ssl  Oct24 186:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1607  0.3  0.3 1099876 63916 ?       Ssl  Oct24 186:14 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1705  0.3  0.3 1100392 64852 ?       Ssl  Oct24 186:04 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1706  0.3  0.3 1100132 63436 ?       Ssl  Oct24 186:07 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1805  0.3  0.3 1100384 64376 ?       Ssl  Oct24 186:12 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1807  0.3  0.3 1100128 63984 ?       Ssl  Oct24 182:27 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1885  0.3  0.3 1100136 63404 ?       Ssl  Oct24 183:44 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1886  1.6  0.9 11854324 155420 ?     Ssl  Oct24 751:40 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     2628167  0.8  0.7 1167788 123400 ?      Ssl  Nov04 261:27 node /home/sasa/voovuu/voovuu-api/starter.js
www-data 3146667  0.0  0.0   2608   592 ?        S    00:44   0:00 sh -c ps -aux | grep node
www-data 3146669  0.0  0.0   3304   656 ?        S    00:44   0:00 grep node
sasa     3168557  0.6  0.6 11816140 101388 ?     Ssl  Nov06 182:17 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.4  0.5 11798408 83184 ?      Ssl  Nov06 119:50 node /home/sasa/@mikosoft/dodo-examples/server/index.js