..:: 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        1208  0.3  0.4 1304488 72540 ?       Ssl   2025 1104:47 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1236  0.5  0.6 11821528 105936 ?     Ssl   2025 1745:57 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1304584 71788 ?       Ssl   2025 1120:11 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1298028 66964 ?       Ssl   2025 1103:17 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.3  2.6 12142716 439680 ?     Ssl   2025 14048:30 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  5.2  3.5 12234652 575688 ?     Ssl   2025 16749:14 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1214480  0.3  0.7 22311168 125944 ?     Ssl   2025 854:40 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1101312 65700 ?       Ssl   2025 765:14 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1101060 65632 ?       Ssl   2025 763:42 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.4 1102824 67032 ?       Ssl   2025 769:34 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.4 1101316 66376 ?       Ssl   2025 765:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.3 1100672 65036 ?       Ssl   2025 763:16 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.4 1167976 66616 ?       Ssl   2025 753:36 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1100128 64592 ?       Ssl   2025 750:46 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.7  0.7 11844444 124612 ?     Ssl   2025 1616:36 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.4 1101560 65740 ?       Ssl   2025 762:49 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1399960  0.8  0.7 11826268 114908 ?     Ssl  Apr20 517:17 node /home/sasa/dex8/dex8-www/server/index.js
sasa     1631573  0.4  0.4 1302312 75980 ?       Ssl  May31  23:43 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa     1904154  0.6  0.8 11857396 138588 ?     Ssl  Apr25 345:00 node /home/sasa/miko/miko-hr/server/index.js
sasa     2035035  0.3  0.3 1100380 64936 ?       Ssl  04:02   3:07 node /home/sasa/dex8/dex8-worker/starter.js
www-data 2109413  0.0  0.0   2608   592 ?        S    20:29   0:00 sh -c ps -aux | grep node
www-data 2109415  0.0  0.0   3304   720 ?        S    20:29   0:00 grep node
sasa     2628167  0.8  0.8 1176920 131908 ?      Ssl   2025 2503:32 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.6 11835448 110484 ?     Ssl   2025 1850:59 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 84268 ?      Ssl   2025 1540:17 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.7  0.5 1332680 86040 ?       Ssl  Feb21 1040:11 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js