..:: 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 1303860 82688 ?       Ssl  Oct24 125:27 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1200  1.0  0.8 11722276 137612 ?     Ssl  Oct24 230:37 node /home/sasa/dex8/dex8-api/starter.js
sasa        1207  0.4  0.4 1303736 71676 ?       Ssl  Oct24  96:38 node /home/sasa/regoch/regoch-www/server
sasa        1208  0.4  0.4 1304656 72704 ?       Ssl  Oct24  89:31 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  1.0  0.6 11824452 101496 ?     Ssl  Oct24 236:15 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.6  0.5 11810572 94344 ?      Ssl  Oct24 132:47 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1255  0.7  0.4 1329104 81684 ?       Ssl  Oct24 172:57 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1257  0.4  0.4 1300596 69352 ?       Ssl  Oct24  90:46 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.4  0.3 1297036 65044 ?       Ssl  Oct24  89:38 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  3.0  2.7 12142188 444280 ?     Ssl  Oct24 672:35 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1449  0.4  0.3 1165544 63604 ?       Ssl  Oct24  94:04 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1528  2.1  2.6 22633988 426504 ?     Ssl  Oct24 467:17 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1529  0.4  0.4 1102692 66960 ?       Ssl  Oct24  93:51 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1606  0.4  0.4 1102692 66392 ?       Ssl  Oct24  94:07 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1607  0.4  0.4 1102692 66732 ?       Ssl  Oct24  93:44 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1705  0.4  0.4 1102952 67688 ?       Ssl  Oct24  93:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1706  0.4  0.4 1102948 67024 ?       Ssl  Oct24  93:42 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1805  0.4  0.4 1102688 67408 ?       Ssl  Oct24  93:39 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1807  0.4  0.3 1100128 64096 ?       Ssl  Oct24  91:47 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1885  0.4  0.3 1099112 63700 ?       Ssl  Oct24  92:00 node /home/sasa/dex8/dex8-worker/starter.js
sasa        1886  1.2  0.8 11833136 131176 ?     Ssl  Oct24 281:13 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     2628167  1.0  0.6 1153624 107224 ?      Ssl  Nov04  62:49 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.7  0.5 11807264 88584 ?      Ssl  Nov06  24:44 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.6  0.4 11796872 81072 ?      Ssl  Nov06  19:42 node /home/sasa/@mikosoft/dodo-examples/server/index.js
www-data 3696270  0.0  0.0   2608   592 ?        S    21:53   0:00 sh -c ps -aux | grep node
www-data 3696272  0.0  0.0   3304   720 ?        R    21:53   0:00 grep node