本文整理匯總了TypeScript中vs/base/common/strings.createRegExp函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createRegExp函數的具體用法?TypeScript createRegExp怎麽用?TypeScript createRegExp使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了createRegExp函數的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: parseSearchRequest
public parseSearchRequest(): RegExp {
if (this.searchString === '') {
return null;
}
// Try to create a RegExp out of the params
let multiline: boolean;
if (this.isRegex) {
multiline = SearchParams._isMultilineRegexSource(this.searchString);
} else {
multiline = (this.searchString.indexOf('\n') >= 0);
}
let regex: RegExp = null;
try {
regex = strings.createRegExp(this.searchString, this.isRegex, {
matchCase: this.matchCase,
wholeWord: this.wholeWord,
multiline,
global: true
});
} catch (err) {
return null;
}
if (!regex) {
return null;
}
return regex;
}
示例2: _rangeIsMatch
private _rangeIsMatch(range:Range): boolean {
let selection = this._editor.getSelection();
let selectionText = this._editor.getModel().getValueInRange(selection);
let regexp = strings.createRegExp(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord, true);
let m = selectionText.match(regexp);
return (m && m[0].length === selectionText.length);
}
示例3: getReplaceString
private getReplaceString(matchedString:string): string {
if (!this._state.isRegex) {
return this._state.replaceString;
}
let regexp = strings.createRegExp(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord, true);
// Parse the replace string to support that \t or \n mean the right thing
let parsedReplaceString = parseReplaceString(this._state.replaceString);
return matchedString.replace(regexp, parsedReplaceString);
}
示例4: parseSearchRequest
public parseSearchRequest(): SearchData {
if (this.searchString === '') {
return null;
}
// Try to create a RegExp out of the params
let multiline: boolean;
if (this.isRegex) {
multiline = SearchParams._isMultilineRegexSource(this.searchString);
} else {
multiline = (this.searchString.indexOf('\n') >= 0);
}
let regex: RegExp = null;
try {
regex = strings.createRegExp(this.searchString, this.isRegex, {
matchCase: this.matchCase,
wholeWord: false,
multiline: multiline,
global: true
});
} catch (err) {
return null;
}
if (!regex) {
return null;
}
let canUseSimpleSearch = (!this.isRegex && !multiline);
if (canUseSimpleSearch && this.searchString.toLowerCase() !== this.searchString.toUpperCase()) {
// casing might make a difference
canUseSimpleSearch = this.matchCase;
}
return new SearchData(regex, this.wordSeparators ? getMapForWordSeparators(this.wordSeparators) : null, canUseSimpleSearch ? this.searchString : null);
}
示例5: createOrRegex
function createOrRegex(pieces:string[]): RegExp {
let regexStr = `(${pieces.map(strings.escapeRegExpCharacters).join(')|(')})`;
return strings.createRegExp(regexStr, true, false, false, false);
}
示例6: createBracketOrRegExp
function createBracketOrRegExp(pieces: string[]): RegExp {
let regexStr = `(${pieces.map(prepareBracketForRegExp).join(')|(')})`;
return strings.createRegExp(regexStr, true);
}