123456789101112131415161718192021222324 |
- /**
- * Helper to manipulate strings
- */
- export class StringTools {
- /**
- * Checks for a matching suffix at the end of a string (for ES5 and lower)
- * @param str Source string
- * @param suffix Suffix to search for in the source string
- * @returns Boolean indicating whether the suffix was found (true) or not (false)
- */
- public static EndsWith(str: string, suffix: string): boolean {
- return str.indexOf(suffix, str.length - suffix.length) !== -1;
- }
- /**
- * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
- * @param str Source string
- * @param suffix Suffix to search for in the source string
- * @returns Boolean indicating whether the suffix was found (true) or not (false)
- */
- public static StartsWith(str: string, suffix: string): boolean {
- return str.indexOf(suffix) === 0;
- }
- }
|