..:: 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 1304968 83372 ?       Ssl   2025 1021:47 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1305000 73300 ?       Ssl   2025 732:47 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.8  0.7 11840960 122292 ?     Ssl   2025 1625:56 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.6 11822008 105464 ?     Ssl   2025 1159:18 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1304152 72572 ?       Ssl   2025 744:03 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1301840 70844 ?       Ssl   2025 731:32 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.5  3.0 12187716 496380 ?     Ssl   2025 9121:47 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  3.2  1.9 12002700 323260 ?     Ssl   2025 6462:09 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1189886  0.3  0.3 1099100 63392 ?       Ssl  03:04   4:05 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214480  0.4  0.7 22311424 126364 ?     Ssl   2025 438:14 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1101056 66264 ?       Ssl   2025 368:23 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.3 1100548 65368 ?       Ssl   2025 367:28 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.3 1100776 64992 ?       Ssl   2025 370:01 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1100548 64332 ?       Ssl   2025 368:19 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1100672 65700 ?       Ssl   2025 367:24 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.4 1102952 67168 ?       Ssl   2025 362:03 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.4 1102688 65976 ?       Ssl   2025 360:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.7  0.7 11708808 123260 ?     Ssl   2025 784:40 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1100792 64592 ?       Ssl   2025 366:53 node /home/sasa/dex8/dex8-worker/starter.js
www-data 1282874  0.0  0.0   2608   528 ?        S    23:42   0:00 sh -c ps -aux | grep node
www-data 1282876  0.0  0.0   3304   724 ?        S    23:42   0:00 grep node
sasa     2509059  0.6  0.5 11802164 92428 ?      Ssl  Feb14 228:11 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.8  0.8 1177688 133328 ?      Ssl   2025 1629:24 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.6 11816080 99460 ?      Ssl   2025 1160:45 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 85184 ?      Ssl   2025 945:02 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.6  0.5 1330104 82540 ?       Ssl  Feb21 175:03 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js