import { Injectable } from '@angular/core' ; /**
 * Contains different common regex expressions for shared quick access.
 */ @ Injectable ( ) export class RegexService { private regex : Object = { url : /(\b(https?|ftp|file):\/\/[^\s\]]+(?:[^!?\s]))/gim , mail : /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/gim , hash : new RegExp ( [ '([^&]|\\b|^)' , '#' , '([' , '\\wÀ-ÿ' , '\\u0E00-\\u0E7F' , '\\u2460-\\u9FBB' , ']+)' , ] . join ( '' ) , 'gim' ) , crypto : new RegExp ( [ '([^&]|\\b|^)' , '\\$' , '([' , 'A-Za-z' , ']+)' , ] . join ( '' ) , 'gim' ) , at : /(^|\W|\s)@([a-z0-9_\-\.]+[a-z0-9_])/gim , } ; /**
     * Get regex for url, mail, hash or at.
     */ public getRegex ( key ) { return this . regex [ key ] ; } }