..:: 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 1304276 81936 ?       Ssl  Oct24 182:01 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1200  0.9  0.8 11722168 138196 ?     Ssl  Oct24 310:38 node /home/sasa/dex8/dex8-api/starter.js
sasa        1207  0.4  0.4 1305044 73364 ?       Ssl  Oct24 143:28 node /home/sasa/regoch/regoch-www/server
sasa        1208  0.4  0.4 1304912 72536 ?       Ssl  Oct24 130:20 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  1.0  0.6 11824164 101836 ?     Ssl  Oct24 326:19 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.6  0.5 11812620 97008 ?      Ssl  Oct24 197:05 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1255  0.7  0.4 1329104 81560 ?       Ssl  Oct24 254:47 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1257  0.4  0.4 1300548 69432 ?       Ssl  Oct24 132:15 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.4  0.4 1297184 65748 ?       Ssl  Oct24 130:37 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  3.1  3.1 12198708 508996 ?     Ssl  Oct24 1005:56 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1449  0.4  0.3 1165544 63688 ?       Ssl  Oct24 137:00 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1528  1.7  2.6 22621264 429956 ?     Ssl  Oct24 552:01 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1529  0.4  0.4 1101924 66000 ?       Ssl  Oct24 136:55 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1606  0.4  0.4 1101924 66156 ?       Ssl  Oct24 136:59 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1607  0.4  0.4 1101924 66700 ?       Ssl  Oct24 136:33 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1705  0.4  0.4 1102184 67064 ?       Ssl  Oct24 136:10 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1706  0.4  0.4 1102180 66572 ?       Ssl  Oct24 136:28 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1805  0.4  0.4 1101920 66356 ?       Ssl  Oct24 136:30 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1807  0.4  0.3 1100128 64644 ?       Ssl  Oct24 133:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1885  0.4  0.3 1098856 64448 ?       Ssl  Oct24 134:17 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1886  1.4  0.8 11841760 143668 ?     Ssl  Oct24 467:21 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
www-data  317288  0.0  0.0   2608   596 ?        S    22:16   0:00 sh -c ps -aux | grep node
www-data  317290  0.0  0.0   3304   716 ?        S    22:16   0:00 grep node
sasa     2628167  0.9  0.7 1160996 115984 ?      Ssl  Nov04 152:41 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.7  0.5 11821476 95220 ?      Ssl  Nov06  95:32 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.4  0.5 11798408 83616 ?      Ssl  Nov06  65:14 node /home/sasa/@mikosoft/dodo-examples/server/index.js