..:: 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 1306652 86240 ?       Ssl   2025 1320:28 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1302184 70728 ?       Ssl   2025 951:09 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1236  0.5  0.6 11818836 108516 ?     Ssl   2025 1503:56 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1304920 73636 ?       Ssl   2025 964:56 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1298364 68724 ?       Ssl   2025 949:46 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.5  2.7 12147524 450320 ?     Ssl   2025 12345:38 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  4.1  2.7 12115032 449300 ?     Ssl   2025 11202:58 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1214480  0.3  0.7 22311168 125792 ?     Ssl   2025 683:22 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1101312 66076 ?       Ssl   2025 601:57 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1103108 68444 ?       Ssl   2025 600:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.4 1101800 65688 ?       Ssl   2025 604:54 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1100804 64576 ?       Ssl   2025 601:54 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.3 1101184 65516 ?       Ssl   2025 600:19 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1100648 64296 ?       Ssl   2025 591:31 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1100128 63280 ?       Ssl   2025 589:21 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.6  0.7 11708864 123880 ?     Ssl   2025 1169:47 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1100792 64228 ?       Ssl   2025 599:46 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1399960  0.7  2.7 12149352 454976 ?     Rsl  Apr20 108:38 node /home/sasa/dex8/dex8-www/server/index.js
sasa     1904154  0.5  0.6 11827964 101588 ?     Ssl  Apr25  43:28 node /home/sasa/miko/miko-hr/server/index.js
sasa     2322057  0.3  0.5 22294164 98196 ?      Ssl  Apr29   7:33 node /home/sasa/dex8/dex8-worker/starter.js
www-data 2491772  0.0  0.0   2608   592 ?        S    17:37   0:00 sh -c ps -aux | grep node
www-data 2491774  0.0  0.0   3304   648 ?        S    17:37   0:00 grep node
sasa     2628167  0.8  0.8 1179224 132460 ?      Ssl   2025 2161:21 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11803840 93832 ?      Ssl   2025 1565:04 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 83856 ?      Ssl   2025 1294:56 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.7  0.5 1332748 86556 ?       Ssl  Feb21 685:17 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js