..:: 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 1305760 83876 ?       Ssl   2025 1464:01 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1305000 72240 ?       Ssl   2025 1041:42 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1236  0.5  0.6 11818960 106048 ?     Ssl   2025 1645:48 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1257  0.3  0.4 1304920 72820 ?       Ssl   2025 1056:23 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1297836 67904 ?       Ssl   2025 1040:20 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.5  2.8 12156028 465104 ?     Ssl   2025 13539:16 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  4.7  3.4 12221156 563168 ?     Ssl   2025 14262:01 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa      426910  0.3  0.3 1099612 64116 ?       Ssl  04:02   3:00 node /home/sasa/dex8/dex8-worker/starter.js
www-data  497599  0.0  0.0   2608   596 ?        S    19:37   0:00 sh -c ps -aux | grep node
www-data  497601  0.0  0.0   3304   708 ?        S    19:37   0:00 grep node
sasa     1214480  0.3  0.7 22311168 125700 ?     Ssl   2025 784:29 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.3 1101312 65076 ?       Ssl   2025 698:20 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1101572 65984 ?       Ssl   2025 696:50 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.4 1101544 65708 ?       Ssl   2025 702:06 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1101316 64952 ?       Ssl   2025 698:32 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1102208 67300 ?       Ssl   2025 696:27 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.4 1167464 66444 ?       Ssl   2025 686:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1100128 64460 ?       Ssl   2025 684:09 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.7  0.8 11845212 131244 ?     Ssl   2025 1505:46 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1101816 65420 ?       Ssl   2025 695:55 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1399960  0.8  0.6 11806812 110380 ?     Ssl  Apr20 368:57 node /home/sasa/dex8/dex8-www/server/index.js
sasa     1904154  0.6  0.6 11811128 102364 ?     Ssl  Apr25 221:23 node /home/sasa/miko/miko-hr/server/index.js
sasa     2628167  0.8  0.8 1176920 132544 ?      Ssl   2025 2371:09 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.6 11825352 100968 ?     Ssl   2025 1732:50 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11799176 84700 ?      Ssl   2025 1439:29 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3264954  0.7  0.5 1332492 86200 ?       Ssl  Feb21 895:40 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js