Skip to content

Commit

Permalink
Fix regex expression
Browse files Browse the repository at this point in the history
  • Loading branch information
ggetz committed Apr 30, 2018
1 parent 9a74dcd commit 8fce932
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions Source/Scene/ModelUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,12 @@ define([
}
};

function regexIndexOf(text, regex, i) {
var indexInSuffix = text.slice(i).search(regex);
return indexInSuffix < 0 ? indexInSuffix : indexInSuffix + i;
}

function replaceAllButFirstInString(string, find, replace) {
// Limit search to strings that are not a subset of other tokens.
find += '(?![a-zA-Z_$])';
find += '(?![a-zA-Z0-9_])';
find = new RegExp(find, 'g');

var index = regexIndexOf(string, find, 0);
var index = string.search(find);
return string.replace(find, function(match, offset) {
return index === offset ? match : replace;
});
Expand Down

0 comments on commit 8fce932

Please sign in to comment.