..:: 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 1304140 82076 ?       Ssl   2025 828:32 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1305000 73468 ?       Ssl   2025 590:28 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.8  0.7 11829044 118228 ?     Ssl   2025 1323:04 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.6 11818152 105148 ?     Ssl   2025 933:50 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1255  0.8  0.5 1331116 84940 ?       Ssl   2025 1285:29 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1257  0.3  0.4 1304408 72704 ?       Ssl   2025 600:10 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1298092 67692 ?       Ssl   2025 589:39 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.4  2.8 12163140 461076 ?     Ssl   2025 6960:47 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  2.9  1.5 11948192 258356 ?     Ssl   2025 4667:51 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1214480  0.4  0.7 22311424 125904 ?     Ssl   2025 279:09 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1103104 66936 ?       Ssl   2025 216:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1103108 67968 ?       Ssl   2025 216:01 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.4 1102056 66036 ?       Ssl   2025 217:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.4 1102852 66600 ?       Ssl   2025 216:25 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1102464 67508 ?       Ssl   2025 216:00 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1099624 63548 ?       Ssl   2025 212:49 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1099616 63080 ?       Ssl   2025 212:02 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.8  0.7 11709576 123900 ?     Ssl   2025 533:17 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.4 1102328 66128 ?       Ssl   2025 215:15 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1893167  0.3  0.3 1099356 64344 ?       Ssl  03:03   3:04 node /home/sasa/dex8/dex8-worker/starter.js
www-data 1962743  0.0  0.0   2608   596 ?        S    18:22   0:00 sh -c ps -aux | grep node
www-data 1962745  0.0  0.0   3304   708 ?        S    18:22   0:00 grep node
sasa     2628167  0.9  0.7 1175228 129572 ?      Ssl   2025 1279:14 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.6 11823592 99264 ?      Ssl   2025 909:17 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11798920 84668 ?      Ssl   2025 716:13 node /home/sasa/@mikosoft/dodo-examples/server/index.js