本文整理汇总了TypeScript中angular2/src/facade/lang.RegExpWrapper.create方法的典型用法代码示例。如果您正苦于以下问题:TypeScript RegExpWrapper.create方法的具体用法?TypeScript RegExpWrapper.create怎么用?TypeScript RegExpWrapper.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类angular2/src/facade/lang.RegExpWrapper
的用法示例。
在下文中一共展示了RegExpWrapper.create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: _propertiesFromRule
_propertiesFromRule(rule): string {
var cssText = rule.style.cssText;
// TODO(sorvell): Safari cssom incorrectly removes quotes from the content
// property. (https://bugs.webkit.org/show_bug.cgi?id=118045)
// don't replace attr rules
var attrRe = RegExpWrapper.create('[\'"]+|attr');
if (rule.style.content.length > 0 &&
!isPresent(RegExpWrapper.firstMatch(attrRe, rule.style.content))) {
var contentRe = RegExpWrapper.create('content:[^;]*;');
cssText =
StringWrapper.replaceAll(cssText, contentRe, 'content: \'' + rule.style.content + '\';');
}
// TODO(sorvell): we can workaround this issue here, but we need a list
// of troublesome properties to fix https://github.com/Polymer/platform/issues/53
//
// inherit rules can be omitted from cssText
// TODO(sorvell): remove when Blink bug is fixed:
// https://code.google.com/p/chromium/issues/detail?id=358273
// var style = rule.style;
// for (var i = 0; i < style.length; i++) {
// var name = style.item(i);
// var value = style.getPropertyValue(name);
// if (value == 'initial') {
// cssText += name + ': initial; ';
// }
//}
return cssText;
}
示例2: _makeScopeMatcher
_makeScopeMatcher(scopeSelector) {
var lre = RegExpWrapper.create('\\[');
var rre = RegExpWrapper.create('\\]');
scopeSelector = StringWrapper.replaceAll(scopeSelector, lre, '\\[');
scopeSelector = StringWrapper.replaceAll(scopeSelector, rre, '\\]');
return RegExpWrapper.create('^(' + scopeSelector + ')' + _selectorReSuffix, 'm');
}
示例3: _propertiesFromRule
_propertiesFromRule(rule) {
var cssText = rule.style.cssText;
var attrRe = RegExpWrapper.create('[\'"]+|attr');
if (rule.style.content.length > 0 && !isPresent(RegExpWrapper.firstMatch(attrRe, rule.style.content))) {
var contentRe = RegExpWrapper.create('content:[^;]*;');
cssText = StringWrapper.replaceAll(cssText, contentRe, 'content: \'' + rule.style.content + '\';');
}
return cssText;
}
示例4: normalizeCSS
export function normalizeCSS(css: string): string {
css = StringWrapper.replaceAll(css, RegExpWrapper.create('\\s+'), ' ');
css = StringWrapper.replaceAll(css, RegExpWrapper.create(':\\s'), ':');
css = StringWrapper.replaceAll(css, RegExpWrapper.create("\\'"), '"');
css = StringWrapper.replaceAllMapped(css, RegExpWrapper.create('url\\(\\"(.+)\\"\\)'),
(match) => `url(${match[1]})`);
css = StringWrapper.replaceAllMapped(css, RegExpWrapper.create('\\[(.+)=([^"\\]]+)\\]'),
(match) => `[${match[1]}="${match[2]}"]`);
return css;
}
示例5: _applyStrictSelectorScope
// return a selector with [name] suffix on each simple selector
// e.g. .foo.bar > .zot becomes .foo[name].bar[name] > .zot[name]
_applyStrictSelectorScope(selector: string, scopeSelector: string): string {
var isRe = RegExpWrapper.create('\\[is=([^\\]]*)\\]');
scopeSelector = StringWrapper.replaceAllMapped(scopeSelector, isRe, (m) => m[1]);
var splits = [' ', '>', '+', '~'],
scoped = selector,
attrName = '[' + scopeSelector + ']';
for (var i = 0; i < splits.length; i++) {
var sep = splits[i];
var parts = scoped.split(sep);
scoped = ListWrapper.map(parts, function(p) {
// remove :host since it should be unnecessary
var t = StringWrapper.replaceAll(p.trim(), _polyfillHostRe, '');
if (t.length > 0 &&
!ListWrapper.contains(splits, t) &&
!StringWrapper.contains(t, attrName)) {
var re = RegExpWrapper.create('([^:]*)(:*)(.*)');
var m = RegExpWrapper.firstMatch(re, t);
if (isPresent(m)) {
p = m[1] + attrName + m[2] + m[3];
}
}
return p;
}).join(sep);
}
return scoped;
}
示例6: it
it('should return a new string with the pattern replaced', () => {
var result1 = pipe.transform(str, ['Douglas', 'Hugh']);
var result2 = pipe.transform(str, [RegExpWrapper.create('a'), '_']);
var result3 = pipe.transform(str, [RegExpWrapper.create('a', 'i'), '_']);
var f = (x => { return 'Adams!'; });
var result4 = pipe.transform(str, ['Adams', f]);
var result5 = pipe.transform(someNumber, ['2', '4']);
expect(result1).toEqual('Hugh Adams');
expect(result2).toEqual('Dougl_s Ad_ms');
expect(result3).toEqual('Dougl_s _d_ms');
expect(result4).toEqual('Douglas Adams!');
expect(result5).toEqual('44');
});
示例7: function
scoped = ListWrapper.map(parts, function(p) {
var t = StringWrapper.replaceAll(p.trim(), _polyfillHostRe, '');
if (t.length > 0 && !ListWrapper.contains(splits, t) && !StringWrapper.contains(t, attrName)) {
var re = RegExpWrapper.create('([^:]*)(:*)(.*)');
var m = RegExpWrapper.firstMatch(re, t);
if (isPresent(m)) {
p = m[1] + attrName + m[2] + m[3];
}
}
return p;
}).join(sep);
示例8: it
it('should expose the index for each match', () => {
var re = RegExpWrapper.create('(!)');
var matcher = RegExpWrapper.matcher(re, '0!23!567!!');
var indexes = [];
var m;
while (isPresent(m = RegExpMatcherWrapper.next(matcher))) {
ListWrapper.push(indexes, m.index);
expect(m[0]).toEqual('!');
expect(m[1]).toEqual('!');
expect(m.length).toBe(2);
}
expect(indexes).toEqual([1, 4, 8, 9]);
});
示例9: parseParams
parseParams(url: string): StringMap<string, string> {
var params = StringMapWrapper.create();
var urlPart = url;
for (var i = 0; i < this.segments.length; i++) {
var segment = this.segments[i];
var match = RegExpWrapper.firstMatch(RegExpWrapper.create('/' + segment.regex), urlPart);
urlPart = StringWrapper.substring(urlPart, match[0].length);
if (segment.name.length > 0) {
StringMapWrapper.set(params, segment.name, match[1]);
}
}
return params;
}