..:: 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.4  0.5 1306052 85696 ?       Ssl   2025 1339:33 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1303208 71456 ?       Ssl   2025 964:49 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1236  0.5  0.6 11819604 106680 ?     Ssl   2025 1525:26 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1305176 74052 ?       Ssl   2025 978:44 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1299884 67900 ?       Ssl   2025 963:31 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.5  3.1 12199436 512844 ?     Ssl   2025 12493:16 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  4.2  2.8 12131252 467160 ?     Ssl   2025 11598:33 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1214480  0.3  0.7 22311168 125368 ?     Ssl   2025 698:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1101568 66224 ?       Ssl   2025 616:30 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1100804 65600 ?       Ssl   2025 615:11 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.3 1101032 65316 ?       Ssl   2025 619:34 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1100548 64068 ?       Ssl   2025 616:31 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1100672 65532 ?       Ssl   2025 614:52 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1100648 64976 ?       Ssl   2025 605:50 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1100128 63736 ?       Ssl   2025 603:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.6  0.7 11710796 125392 ?     Ssl   2025 1194:03 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1100280 64620 ?       Ssl   2025 614:17 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1399960  0.9  0.6 11806300 106500 ?     Ssl  Apr20 168:03 node /home/sasa/dex8/dex8-www/server/index.js
sasa     1904154  0.5  0.6 11829200 102632 ?     Ssl  Apr25  70:58 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.8  0.8 1176408 132628 ?      Ssl   2025 2191:28 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     2757401  0.3  0.3 1098844 64216 ?       Ssl  04:03   2:47 node /home/sasa/dex8/dex8-worker/starter.js
www-data 2820872  0.0  0.0   2608   528 ?        S    18:18   0:00 sh -c ps -aux | grep node
www-data 2820874  0.0  0.0   3304   716 ?        S    18:18   0:00 grep node
sasa     3168557  0.6  0.6 11826368 101928 ?     Ssl   2025 1591:08 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 84148 ?      Ssl   2025 1316:48 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.7  0.5 1332748 86856 ?       Ssl  Feb21 717:09 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js