fork(3) download
  1. str = 'foo myfoo http://t...content-available-to-author-only...r.com/food is awesome';
  2. str = str.replace(/\bfoo\b/g, 'bar');
  3. while (/http:\/\/[^\s]*?foo/.test(str))
  4. str = str.replace(/(http:\/\/[^\s]*?)?foo/g, function($0, $1) {
  5. return $1 ? $1 + 'bar' : $0;
  6. });
  7. print(str);
  8.  
Success #stdin #stdout 0.02s 5084KB
stdin
1
2
10
42
11
stdout
bar myfoo http://t...content-available-to-author-only...r.com/bard is awesome