..:: 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 1306128 83648 ?       Ssl   2025 957:53 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1305000 72944 ?       Ssl   2025 686:13 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.8  0.7 11828284 118620 ?     Ssl   2025 1524:27 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.5  0.6 11820400 108852 ?     Ssl   2025 1085:31 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1305176 72876 ?       Ssl   2025 696:53 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1298668 67584 ?       Ssl   2025 685:02 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.5  2.8 12167804 463312 ?     Ssl   2025 8561:21 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  3.1  1.6 11955544 268596 ?     Rsl   2025 5818:47 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
www-data  110100  0.0  0.0   2608   592 ?        S    21:42   0:00 sh -c ps -aux | grep node
www-data  110102  0.0  0.0   3304   716 ?        S    21:42   0:00 grep node
sasa     1214480  0.4  0.7 22311424 125816 ?     Ssl   2025 385:59 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.3 1101056 64828 ?       Ssl   2025 318:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1101060 65556 ?       Ssl   2025 317:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.3 1101288 65004 ?       Ssl   2025 320:07 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1100548 65276 ?       Ssl   2025 318:30 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1100672 65672 ?       Ssl   2025 317:46 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1100392 63896 ?       Ssl   2025 313:08 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1099872 63540 ?       Ssl   2025 311:59 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.7  0.7 11708296 122600 ?     Ssl   2025 702:26 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1100536 64012 ?       Ssl   2025 317:15 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2509059  0.6  0.5 11802612 94324 ?      Ssl  Feb14 144:18 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.8  0.7 1176408 130784 ?      Ssl   2025 1522:00 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.5 11812304 94984 ?      Ssl   2025 1079:02 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11798920 84944 ?      Ssl   2025 870:10 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.6  0.5 1330464 83368 ?       Ssl  Feb21  80:15 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa     4189979  0.3  0.4 1102180 67720 ?       Ssl  03:02   3:45 node /home/sasa/dex8/dex8-worker/starter.js