..:: 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        1197  1.2  0.6 1327004 100032 ?      Ssl  Oct18 431:01 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1211  6.9  0.7 11845888 124908 ?     Ssl  Oct18 2507:25 node /home/sasa/dex8/dex8-api/starter.js
sasa        1218  0.4  0.4 11794352 76272 ?      Ssl  Oct18 161:33 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1219  0.8  0.6 11816224 106724 ?     Ssl  Oct18 289:38 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1232  0.4  0.5 11809468 92164 ?      Ssl  Oct18 168:36 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1248  0.6  0.5 1332152 83868 ?       Ssl  Oct18 232:41 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1274  0.3  0.4 1310052 76920 ?       Ssl  Oct18 113:32 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1277  0.3  0.3 1296096 62448 ?       Ssl  Oct18 111:49 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1337  0.7  0.7 1166216 118592 ?      Ssl  Oct18 252:28 node /home/sasa/voovuu/voovuu-api/starter.js
sasa        1385  4.1  4.3 12409896 719732 ?     Rsl  Oct18 1483:33 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1387  0.3  0.4 11797708 81132 ?      Ssl  Oct18 125:15 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa        1457  0.3  0.3 1099104 61500 ?       Ssl  Oct18 113:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1458  0.3  0.4 22279596 78632 ?      Ssl  Oct18 116:12 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1514  0.3  0.3 1099236 62120 ?       Ssl  Oct18 113:23 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1515  0.3  0.3 1099364 61996 ?       Ssl  Oct18 113:04 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1593  0.3  0.3 1099360 62216 ?       Ssl  Oct18 113:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1595  0.3  0.3 1098848 61936 ?       Ssl  Oct18 113:24 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1660  0.3  0.3 1099248 62460 ?       Ssl  Oct18 113:07 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1661  0.3  0.3 1099104 62196 ?       Ssl  Oct18 113:13 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1732  0.3  0.3 1099104 62472 ?       Ssl  Oct18 113:18 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1734  0.3  0.3 1099360 62648 ?       Ssl  Oct18 112:53 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1792  2.5  3.9 12345948 640892 ?     Ssl  Oct18 915:59 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa      367471  1.1  1.0 11874648 175036 ?     Ssl  Oct21 355:30 node /home/sasa/miko/miko-hr/server/index.js
sasa     2446447  0.4  0.6 11851772 111204 ?     Ssl  Nov09  17:38 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     2511306  0.5  0.5 1330124 83996 ?       Ssl  Nov10  15:44 node /home/sasa/miko/miko-hr/api/starter.js
www-data 2715682  0.0  0.0   2608   592 ?        S    09:22   0:00 sh -c ps -aux | grep node
www-data 2715684  0.0  0.0   3304   712 ?        S    09:22   0:00 grep node