..:: 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 1309664 74116 ?       Ssl   2025 1383:37 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1236  0.5  0.6 11823492 100872 ?     Ssl   2025 2185:01 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1307492 73200 ?       Ssl   2025 1400:47 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1301520 69560 ?       Ssl   2025 1380:15 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.2  4.1 12399800 674584 ?     Ssl   2025 17358:49 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  6.8  3.6 12264388 597888 ?     Ssl   2025 27964:47 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa      535839  0.3  0.5 22292020 95220 ?      Ssl  Aug04   8:31 node /home/sasa/dex8/dex8-worker/starter.js
www-data  756446  0.0  0.0   2608   592 ?        S    02:28   0:00 sh -c ps -aux | grep node
www-data  756448  0.0  0.0   3304   712 ?        S    02:28   0:00 grep node
sasa     1214480  0.3  0.7 22311168 124800 ?     Ssl   2025 1163:50 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.4 1103104 67196 ?       Ssl   2025 1060:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.3 1100804 65076 ?       Ssl   2025 1059:19 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.4 1102312 66256 ?       Ssl   2025 1067:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.4 1102596 66684 ?       Ssl   2025 1062:10 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1102208 66412 ?       Ssl   2025 1058:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.4 1167464 65544 ?       Ssl   2025 1049:53 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1099872 63880 ?       Ssl   2025 1045:03 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.8  0.7 11847612 122716 ?     Ssl   2025 2702:59 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1101816 65200 ?       Ssl   2025 1058:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1399960  0.8  0.6 11808860 108524 ?     Ssl  Apr20 1331:09 node /home/sasa/dex8/dex8-www/server/index.js
sasa     1631573  0.4  0.6 1322748 101488 ?      Ssl  May31 476:41 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa     1904154  0.6  0.9 11848556 150760 ?     Ssl  Apr25 1000:02 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.7  0.7 1175772 130888 ?      Rsl   2025 3138:53 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.6 11811000 101488 ?     Ssl   2025 2427:34 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799488 84128 ?      Ssl   2025 1988:14 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.6  0.5 1333704 87152 ?       Ssl  Feb21 1661:36 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js