How to use the replaceAll function from underscore.string

Find comprehensive JavaScript underscore.string.replaceAll code examples handpicked from public code repositorys.

74
75
76
77
78
79
80
81
82
83
84
app.use(function* (next) {
    var start = new Date();


    var tags = [];
    var cleanMethod = _s.strLeftBack(this.url, '?');
    cleanMethod = _s.replaceAll(cleanMethod, '/', '_');
    cleanMethod = _s.trim(cleanMethod, '_');
    cleanMethod = this.method + '.' + cleanMethod;
    cleanMethod = cleanMethod.toLowerCase();
    tags.push('endpoint:' + cleanMethod);
fork icon0
star icon7
watch icon0

+ 2 other calls in file

8
9
10
11
12
13
14
15
16
17
18


function replaceProjectFile(conf) {
  let buf = fs.readFileSync(conf.targetProj, 'utf-8');
  switch (conf.runtimeLibrary) {
    case 'MultiThreadedDebugDLL':
      buf = s.replaceAll(buf, /(<RuntimeLibrary>)(MultiThreadedDebug)(<\/RuntimeLibrary>)/, `$1${conf.runtimeLibrary}$3`);
      break;
    case 'MultiThreadedDLL':
      buf = s.replaceAll(buf, /(<RuntimeLibrary>)(MultiThreaded)(<\/RuntimeLibrary>)/, `$1${conf.runtimeLibrary}$3`);
      break;
fork icon1
star icon1
watch icon0

+ 3 other calls in file

5
6
7
8
9
10
11
12
13
14
15
16
const buildOneConf = require('./build-one-conf');
const s = require('underscore.string');


function replaceOutputFile(proj) {
  let buf = fs.readFileSync(proj.targetProj, 'utf-8');
  buf = s.replaceAll(buf, /<OutputFile>.*<\/OutputFile>/, '<OutputFile>$(OutDir)$(TargetName)$(TargetExt)<\/OutputFile>');
  fs.writeFileSync(proj.targetProj, buf);
}


function getTargetName(proj) {
fork icon1
star icon1
watch icon0

68
69
70
71
72
73
74
75
76
77
function x5Quote(uri) {
  var ret = encodeURIComponent(uri);
  ret = s.replaceAll(ret, "!", "%21");
  ret = s.replaceAll(ret, "'", "%27");
  ret = s.replaceAll(ret, "\\(", "%28");
  ret = s.replaceAll(ret, "\\)", "%29");
  ret = s.replaceAll(ret, "\\*", "%2A");
  return ret;
}

fork icon0
star icon0
watch icon0

+ 4 other calls in file