export const hasLetters = (x: string): boolean => /[a-z]/i.test(x); export const hasNumbers = (x: string): boolean => /\d/.test(x); export const trimDot = (x: string): string => x.replace(/\.$/, ''); export const withDot = (x: string): string => trimDot(x) + '.'; export const match = (pattern: RegExp, input: string): string[] => { if (typeof input === 'string') { return input.match(pattern) || []; } else { return []; } }; export const matchDigitWithNumber = /(\d+)([a-z]+)/gim; export const UNIX_NEW_LINE_CHAR = '\n'; export const unifyNewLine = (value: string): string => value .replace(/\\n/, UNIX_NEW_LINE_CHAR) .replace(/\r\n?/g, UNIX_NEW_LINE_CHAR); export const splitByNewLine = (value: string): string[] => unifyNewLine(value).split(UNIX_NEW_LINE_CHAR); export const newLinesIntoSpaces = (value: string) => value.replace(/\n/g, ' ');