本文整理匯總了TypeScript中vs/platform/search/common/replace.ReplacePattern.getReplaceString方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ReplacePattern.getReplaceString方法的具體用法?TypeScript ReplacePattern.getReplaceString怎麽用?TypeScript ReplacePattern.getReplaceString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/platform/search/common/replace.ReplacePattern
的用法示例。
在下文中一共展示了ReplacePattern.getReplaceString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: test
test('get replace string for no matches', () => {
let testObject= new ReplacePattern('hello', {pattern: 'bla', isRegExp: true});
let actual= testObject.getReplaceString('foo');
assert.equal(null, actual);
testObject= new ReplacePattern('hello', {pattern: 'bla', isRegExp: false});
actual= testObject.getReplaceString('foo');
assert.equal(null, actual);
});
示例2: getReplaceString
private getReplaceString(matchRange: Range): string {
if (this._state.isRegex) {
let regExp = TextModel.parseSearchRequest(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord);
let replacePattern = new ReplacePattern(this._state.replaceString, true, regExp);
let model = this._editor.getModel();
let matchedString = model.getValueInRange(matchRange);
let replacedString = replacePattern.getReplaceString(matchedString);
// If matched string is not matching then regex pattern has a lookahead expression
if (replacedString === null) {
replacedString = replacePattern.getReplaceString(this._getTextToMatch(matchRange, regExp));
}
return replacedString;
}
return this._state.replaceString;
}
示例3: getReplaceString
private getReplaceString(matchedString:string): string {
let replacePattern= new ReplacePattern(this._state.replaceString, {pattern: this._state.searchString, isRegExp: this._state.isRegex, isCaseSensitive: this._state.matchCase, isWordMatch: this._state.wholeWord});
return replacePattern.getReplaceString(matchedString);
}