diff --git a/src/parsers/abstract-template.parser.ts b/src/parsers/abstract-template.parser.ts index e50d385..c6ac050 100644 --- a/src/parsers/abstract-template.parser.ts +++ b/src/parsers/abstract-template.parser.ts @@ -5,14 +5,15 @@ export abstract class AbstractTemplateParser { * makes the assumption that it is an Angular Component */ protected _isAngularComponent(path: string): boolean { - return new RegExp(/\.ts|js$/, 'i').test(path); + return (/\.ts|js$/i).test(path); } /** * Extracts inline template from components */ protected _extractInlineTemplate(contents: string): string { - const match = new RegExp(/template\s*:\s*(["'`])([^\1]*?)\1/).exec(contents); + const regExp: RegExp = /template\s*:\s*(["'`])([^\1]*?)\1/; + const match = regExp.exec(contents); if (match !== null) { return match[2]; } diff --git a/src/parsers/pipe.parser.ts b/src/parsers/pipe.parser.ts index a00d0ad..12e2f9e 100644 --- a/src/parsers/pipe.parser.ts +++ b/src/parsers/pipe.parser.ts @@ -15,8 +15,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac protected _parseTemplate(template: string): TranslationCollection { let collection: TranslationCollection = new TranslationCollection(); - const regExp = new RegExp(/(['"`])([^\1\r\n]*?)\1\s*\|\s*translate/, 'g'); - + const regExp: RegExp = /(['"`])([^\1\r\n]*?)\1\s*\|\s*translate/g; let matches: RegExpExecArray; while (matches = regExp.exec(template)) { collection = collection.add(matches[2]); diff --git a/src/parsers/service.parser.ts b/src/parsers/service.parser.ts index ec53d35..a7bf654 100644 --- a/src/parsers/service.parser.ts +++ b/src/parsers/service.parser.ts @@ -11,7 +11,7 @@ export class ServiceParser implements ParserInterface { return collection; } - const methodRegExp: RegExp = new RegExp(/(?:get|instant)\s*\(\s*(\[?\s*(['"`])([^\1\r\n]*)\2\s*\]?)/); + const methodRegExp: RegExp = /(?:get|instant)\s*\(\s*(\[?\s*(['"`])([^\1\r\n]*)\2\s*\]?)/; const regExp: RegExp = new RegExp(`${translateServiceVar}\.${methodRegExp.source}`, 'g'); let matches: RegExpExecArray;