本文整理汇总了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;
}
开发者ID:1424667164,项目名称:vscode,代码行数:34,代码来源:textModel.ts
示例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);
}
开发者ID:Elflyy,项目名称:vscode,代码行数:7,代码来源:findModel.ts
示例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);
}
开发者ID:1424667164,项目名称:vscode,代码行数:19,代码来源:textModel.ts
注:本文中的vs/base/common/strings.createSafeRegExp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论