..:: 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 1305256 72652 ?       Ssl   2025 1135:38 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1236  0.5  0.6 11820504 107604 ?     Ssl   2025 1794:11 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1304584 71556 ?       Ssl   2025 1151:13 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1297836 67180 ?       Ssl   2025 1134:01 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.3  3.2 12225804 530736 ?     Ssl   2025 14394:41 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  5.4  3.5 12237304 578316 ?     Ssl   2025 18032:39 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1214480  0.3  0.7 22311168 126016 ?     Ssl   2025 889:11 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.3 1101312 65116 ?       Ssl   2025 798:10 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1101316 66088 ?       Ssl   2025 796:36 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.4 1101288 66308 ?       Ssl   2025 802:44 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1101316 65508 ?       Ssl   2025 798:43 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.3 1100672 65188 ?       Ssl   2025 796:08 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1166440 65068 ?       Ssl   2025 786:38 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1100128 63948 ?       Ssl   2025 783:32 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.7  0.7 11844700 124708 ?     Ssl   2025 1670:49 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.4 1101560 65580 ?       Ssl   2025 795:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1399960  0.8  0.7 11829760 118120 ?     Ssl  Apr20 610:47 node /home/sasa/dex8/dex8-www/server/index.js
sasa     1631573  0.4  0.4 1301620 76916 ?       Ssl  May31  66:42 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa     1904154  0.6  0.8 11855792 136872 ?     Ssl  Apr25 407:29 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.8  0.8 1176796 132564 ?      Ssl   2025 2573:02 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     2719732  0.3  0.6 22293268 98656 ?      Ssl  Jun09   8:17 node /home/sasa/dex8/dex8-worker/starter.js
www-data 2915614  0.0  0.0   2608   528 ?        S    21:54   0:00 sh -c ps -aux | grep node
www-data 2915616  0.0  0.0   3304   648 ?        S    21:54   0:00 grep node
sasa     3168557  0.6  0.6 11836728 112308 ?     Ssl   2025 1909:59 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 83920 ?      Ssl   2025 1589:51 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.7  0.5 1333192 87544 ?       Ssl  Feb21 1111:00 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js