本文整理匯總了TypeScript中vs/base/common/strings.createSafeRegExp函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createSafeRegExp函數的具體用法?TypeScript createSafeRegExp怎麽用?TypeScript createSafeRegExp使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了createSafeRegExp函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: findPreviousMatch
public findPreviousMatch(searchString:string, rawSearchStart:editorCommon.IPosition, isRegex:boolean, matchCase:boolean, wholeWord:boolean): editorCommon.IEditorRange {
if (this._isDisposed) {
throw new Error('Model.findPreviousMatch: Model is disposed');
}
var regex = strings.createSafeRegExp(searchString, isRegex, matchCase, wholeWord);
if (!regex) {
return null;
}
var searchStart = this.validatePosition(rawSearchStart),
lineCount = this.getLineCount(),
startLineNumber = searchStart.lineNumber,
text: string,
r: editorCommon.IEditorRange;
// Look in first line
text = this._lines[startLineNumber - 1].text.substring(0, searchStart.column - 1);
r = this._findLastMatchInLine(regex, text, startLineNumber);
if (r) {
return r;
}
for (var i = 1; i <= lineCount; i++) {
var lineIndex = (lineCount + startLineNumber - i - 1) % lineCount;
text = this._lines[lineIndex].text;
r = this._findLastMatchInLine(regex, text, lineIndex + 1);
if (r) {
return r;
}
}
return null;
}
示例2: _rangeIsMatch
private _rangeIsMatch(range:editorCommon.IEditorRange): boolean {
let selection = this._editor.getSelection();
let selectionText = this._editor.getModel().getValueInRange(selection);
let regexp = strings.createSafeRegExp(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord);
let m = selectionText.match(regexp);
return (m && m[0].length === selectionText.length);
}
示例3: findMatches
public findMatches(searchString:string, rawSearchScope:any, isRegex:boolean, matchCase:boolean, wholeWord:boolean, limitResultCount:number = LIMIT_FIND_COUNT): editorCommon.IEditorRange[] {
if (this._isDisposed) {
throw new Error('Model.findMatches: Model is disposed');
}
var regex = strings.createSafeRegExp(searchString, isRegex, matchCase, wholeWord);
if (!regex) {
return [];
}
var searchRange:editorCommon.IEditorRange;
if (Range.isIRange(rawSearchScope)) {
searchRange = rawSearchScope;
} else {
searchRange = this.getFullModelRange();
}
return this._doFindMatches(searchRange, regex, limitResultCount);
}