..:: 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 1304640 84312 ?       Ssl   2025 677:49 node /home/sasa/.pm2/modules/pm2-logrotate/node_modules/pm2-logr
sasa        1208  0.3  0.4 1305256 73772 ?       Ssl   2025 491:26 node /home/sasa/dex8/dex8-panel/server/index.js
sasa        1224  0.8  0.7 11825928 114788 ?     Ssl   2025 1121:34 node /home/sasa/dex8/dex8-www/server/index.js
sasa        1236  0.6  0.6 11816476 104152 ?     Ssl   2025 776:02 node /home/sasa/mikosoft_hr/www-mikosoft-hr/server/index.js
sasa        1255  0.8  0.5 1331116 85024 ?       Ssl   2025 1065:52 node /home/sasa/mikosoft-info/api-mikosoft-info/starter.js
sasa        1257  0.3  0.4 1304920 72876 ?       Ssl   2025 500:05 node /home/sasa/mikosoft-info/www-mikosoft-info/server/index.js
sasa        1289  0.3  0.4 1298220 67476 ?       Ssl   2025 490:41 node /home/sasa/dex8/dex8-kiosk/server/index.js
sasa        1363  4.3  3.0 12195964 507052 ?     Ssl   2025 5412:32 node /home/sasa/voovuu/voovuu-pub/server/index.js
sasa        1886  2.8  1.2 11896624 203600 ?     Ssl   2025 3552:16 node /home/sasa/mikosoft-info/crypto-mikosoft-info/server/index.
sasa     1214480  0.3  0.3 1099656 64972 ?       Ssl   2025 110:57 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214483  0.3  0.3 1099776 65300 ?       Ssl   2025 111:13 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214536  0.3  0.4 1100036 65992 ?       Ssl   2025 110:48 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214544  0.3  0.3 1100008 65084 ?       Ssl   2025 111:37 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214588  0.3  0.3 1099524 64852 ?       Ssl   2025 110:58 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214617  0.3  0.4 1099904 65888 ?       Ssl   2025 110:46 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214641  0.3  0.3 1099368 63916 ?       Ssl   2025 109:00 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1214671  0.3  0.3 1099104 63264 ?       Ssl   2025 108:41 node /home/sasa/dex8/dex8-worker/starter.js
sasa     1215731  0.5  0.7 11704468 119364 ?     Ssl   2025 182:09 node /home/sasa/dex8/dex8-api/starter.js
sasa     1216489  0.3  0.3 1099768 65132 ?       Ssl   2025 110:15 node /home/sasa/dex8/dex8-worker/starter.js
sasa     2628167  0.9  0.7 1175352 130752 ?      Ssl   2025 1031:44 node /home/sasa/voovuu/voovuu-api/starter.js
sasa     3168557  0.6  0.6 11824592 99780 ?      Ssl   2025 736:37 node /home/sasa/mikosoft-info/dodo-mikosoft-info/server/index.js
sasa     3169051  0.5  0.5 11798920 84412 ?      Ssl   2025 556:58 node /home/sasa/@mikosoft/dodo-examples/server/index.js
sasa     3511899  0.3  0.3 1099100 64256 ?       Ssl  03:03   3:27 node /home/sasa/dex8/dex8-worker/starter.js
www-data 3576173  0.0  0.0   2608   588 ?        S    17:28   0:00 sh -c ps -aux | grep node
www-data 3576175  0.0  0.0   3304   644 ?        S    17:28   0:00 grep node