..:: 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 1305548 84228 ?       Ssl   2025 1040:23 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1305000 73468 ?       Ssl   2025 746:31 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.8  0.7 11830136 118904 ?     Ssl   2025 1653:34 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.6 11817272 107192 ?     Ssl   2025 1180:58 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1304152 71804 ?       Ssl   2025 757:52 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1301872 71724 ?       Ssl   2025 745:11 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.5  2.8 12154492 464204 ?     Ssl   2025 9248:33 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  3.2  1.9 12002908 324404 ?     Ssl   2025 6660:09 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1214480  0.4  0.7 22311424 125680 ?     Ssl   2025 453:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1101824 65840 ?       Ssl   2025 383:03 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1100804 66056 ?       Ssl   2025 382:06 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.3 1101032 64664 ?       Ssl   2025 384:45 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1101060 65168 ?       Ssl   2025 382:59 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.3 1100672 65456 ?       Ssl   2025 382:01 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1100392 63808 ?       Ssl   2025 376:31 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1099616 62892 ?       Ssl   2025 375:01 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.7  0.7 11708808 123492 ?     Ssl   2025 808:47 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1100792 65204 ?       Ssl   2025 381:31 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1515848  0.3  0.3 1099356 63868 ?       Ssl  Mar15   4:19 node /home/sasa/dex8/dex8-worker/starter.js
www-data 1625556  0.0  0.0   2608   528 ?        S    01:15   0:00 sh -c ps -aux | grep node
www-data 1625558  1.0  0.0   3304   656 ?        R    01:15   0:00 grep node
sasa     2509059  0.6  0.6 11825140 102536 ?     Ssl  Feb14 254:27 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.8  0.8 1176920 132604 ?      Ssl   2025 1659:23 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11801232 90672 ?      Ssl   2025 1185:33 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 84968 ?      Ssl   2025 967:07 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.6  0.5 1330104 82908 ?       Ssl  Feb21 204:04 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js