當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript strings.createRegExp函數代碼示例

本文整理匯總了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;
	}
開發者ID:fs814,項目名稱:vscode,代碼行數:31,代碼來源:textModelSearch.ts

示例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);
	}
開發者ID:CCheminaud,項目名稱:vscode,代碼行數:7,代碼來源:findModel.ts

示例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);
	}
開發者ID:Elflyy,項目名稱:vscode,代碼行數:9,代碼來源:findModel.ts

示例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);
	}
開發者ID:JarnoNijboer,項目名稱:vscode,代碼行數:37,代碼來源:textModelSearch.ts

示例5: createOrRegex

function createOrRegex(pieces:string[]): RegExp {
	let regexStr = `(${pieces.map(strings.escapeRegExpCharacters).join(')|(')})`;
	return strings.createRegExp(regexStr, true, false, false, false);
}
開發者ID:13572293130,項目名稱:vscode,代碼行數:4,代碼來源:richEditBrackets.ts

示例6: createBracketOrRegExp

function createBracketOrRegExp(pieces: string[]): RegExp {
	let regexStr = `(${pieces.map(prepareBracketForRegExp).join(')|(')})`;
	return strings.createRegExp(regexStr, true);
}
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:4,代碼來源:richEditBrackets.ts


注:本文中的vs/base/common/strings.createRegExp函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。