..:: 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 1305300 83108 ?       Ssl   2025 1507:26 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1304488 71776 ?       Ssl   2025 1073:25 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1236  0.5  0.6 11822372 106436 ?     Ssl   2025 1696:06 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1304072 71868 ?       Ssl   2025 1088:41 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1298428 67012 ?       Ssl   2025 1072:03 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.4  2.6 12165244 437520 ?     Ssl   2025 13813:12 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  4.9  3.4 12229440 569668 ?     Ssl   2025 15488:19 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1178780  0.3  0.3 1100124 64984 ?       Ssl  04:03   3:06 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214480  0.3  0.7 22311168 125716 ?     Ssl   2025 819:46 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1102592 66372 ?       Ssl   2025 731:55 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1101316 65756 ?       Ssl   2025 730:26 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.4 1101288 66024 ?       Ssl   2025 736:03 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.4 1101316 65936 ?       Ssl   2025 732:18 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.3 1100416 65228 ?       Ssl   2025 730:04 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1166184 64632 ?       Ssl   2025 720:18 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1100128 64832 ?       Ssl   2025 717:35 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.7  0.7 11843932 124536 ?     Ssl   2025 1561:31 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.4 1102584 66568 ?       Ssl   2025 729:33 node /home/sasa/dex8/dex8-worker/starter.js
www-data 1249166  0.0  0.0   2608   596 ?        S    20:10   0:00 sh -c ps -aux | grep node
www-data 1249168  0.0  0.0   3304   716 ?        S    20:10   0:00 grep node
sasa     1399960  0.8  0.6 11814776 112032 ?     Ssl  Apr20 443:33 node /home/sasa/dex8/dex8-www/server/index.js
sasa     1904154  0.5  0.6 11830268 107532 ?     Ssl  Apr25 279:38 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.8  0.8 1176408 131944 ?      Ssl   2025 2438:39 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11803192 91964 ?      Ssl   2025 1791:44 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 84108 ?      Ssl   2025 1490:13 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.7  0.5 1332680 86260 ?       Ssl  Feb21 968:30 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js