..:: 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 1306140 85256 ?       Ssl   2025 1258:47 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1305000 73160 ?       Ssl   2025 906:09 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.7  0.6 11818184 104444 ?     Ssl   2025 2042:50 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.6 11816912 104076 ?     Ssl   2025 1433:35 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1303896 71996 ?       Ssl   2025 919:35 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1297836 67068 ?       Ssl   2025 904:37 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.5  3.9 12335668 646648 ?     Ssl   2025 11758:35 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  3.8  2.7 12108704 442300 ?     Ssl   2025 9993:45 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa      356539  0.5  0.5 11807588 96248 ?      Ssl  Apr11  75:08 node /home/sasa/miko/miko-hr/server/index.js
sasa     1214480  0.3  0.7 22311168 126196 ?     Ssl   2025 632:55 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1101312 65952 ?       Ssl   2025 553:56 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.3 1100804 65516 ?       Ssl   2025 552:43 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.4 1103080 67848 ?       Ssl   2025 556:34 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1100548 64564 ?       Ssl   2025 553:53 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1100928 65748 ?       Ssl   2025 552:24 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1100648 65112 ?       Ssl   2025 544:18 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1100128 63812 ?       Ssl   2025 542:18 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.6  0.7 11709624 124928 ?     Ssl   2025 1090:33 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1100792 64676 ?       Ssl   2025 551:53 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1332840  0.3  0.3 1098848 62916 ?       Ssl  04:04   2:34 node /home/sasa/dex8/dex8-worker/starter.js
www-data 1389984  0.0  0.0   2608   528 ?        S    17:05   0:00 sh -c ps -aux | grep node
www-data 1389986  0.0  0.0   3304   712 ?        S    17:05   0:00 grep node
sasa     2628167  0.8  0.7 1173592 129120 ?      Ssl   2025 2055:30 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11801592 90884 ?      Ssl   2025 1479:41 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 84820 ?      Ssl   2025 1223:00 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.6  0.5 1332612 86508 ?       Ssl  Feb21 577:24 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js