..:: 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 1304776 83792 ?       Ssl   2025 977:12 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1305000 73064 ?       Ssl   2025 700:28 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.8  0.7 11843308 122600 ?     Ssl   2025 1554:09 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.6 11817468 105104 ?     Ssl   2025 1108:06 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1305176 72944 ?       Ssl   2025 711:17 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1302472 70252 ?       Ssl   2025 699:17 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.6  2.9 12175840 476136 ?     Ssl   2025 8770:18 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  3.1  1.9 11994324 315112 ?     Ssl   2025 6002:23 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa      384821  0.3  0.4 1103200 68296 ?       Ssl  03:03   4:03 node /home/sasa/dex8/dex8-worker/starter.js
www-data  481438  0.0  0.0   2608   596 ?        S    23:15   0:00 sh -c ps -aux | grep node
www-data  481440  0.0  0.0   3304   720 ?        S    23:15   0:00 grep node
sasa     1214480  0.4  0.7 22311424 125684 ?     Ssl   2025 401:54 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1101568 65708 ?       Ssl   2025 333:48 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1100804 66108 ?       Ssl   2025 332:58 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.3 1100520 65492 ?       Ssl   2025 335:19 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1100548 64592 ?       Ssl   2025 333:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1100928 66360 ?       Ssl   2025 332:54 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1100136 64600 ?       Ssl   2025 328:05 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1099872 62872 ?       Ssl   2025 326:51 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.7  0.7 11708552 123780 ?     Ssl   2025 727:34 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1100280 64164 ?       Ssl   2025 332:25 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2509059  0.6  0.6 11824560 102432 ?     Ssl  Feb14 170:58 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.8  0.8 1179736 132840 ?      Ssl   2025 1557:11 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11801040 90212 ?      Ssl   2025 1103:45 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11798920 84120 ?      Ssl   2025 893:05 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.6  0.5 1330464 83352 ?       Ssl  Feb21 108:22 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js