Revision 60326
Added by Konstantinos Triantafyllou about 3 years ago
string-utils.class.ts | ||
---|---|---|
187 | 187 |
} |
188 | 188 |
|
189 | 189 |
export class StringUtils { |
190 |
|
|
191 |
public static urlRegex = 'https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' + |
|
192 |
'[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.' + |
|
193 |
'[a-zA-Z0-9]+\.[^\s]{2,}'; |
|
194 |
|
|
190 | 195 |
public static urlPrefix(url: string): string { |
191 | 196 |
if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//")) { |
192 | 197 |
return ""; |
... | ... | |
230 | 235 |
return !!email.match("^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"); |
231 | 236 |
} |
232 | 237 |
|
238 |
public static isValidUrl(url: string): boolean { |
|
239 |
return new RegExp(this.urlRegex).test(url); |
|
240 |
} |
|
241 |
|
|
233 | 242 |
public static urlValidator(): ValidatorFn { |
234 |
return Validators.pattern('https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.' + |
|
235 |
'[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.' + |
|
236 |
'[a-zA-Z0-9]+\.[^\s]{2,}'); |
|
243 |
return Validators.pattern(this.urlRegex); |
|
237 | 244 |
} |
238 | 245 |
|
239 | 246 |
public static sliceString(mystr, size: number): string { |
Also available in: Unified diff
[Library | Trunk]: 1. Fix chips css. 2. Stakeholder Service: Init is Upload after request