webapp/src/intl/chars.ts
2024-09-16 02:41:48 +03:00

17 lines
670 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

export const notChar = /[^\dA-Za-zА-Яа-я]/
export const allChar = /[\dA-Za-zА-Яа-я]/
export const notLatin = /[^A-Za-z]/
export const notRus = /[^ËА-Яа-яё]/
export const sentenceSeparator = /{!|\?|:|;}\s/
export const cyrillicRegex = /[\u0400-\u04FF]/ // Range for Cyrillic characters
export function findFirstReadableCharIndex(input: string): number {
for (let i = 0; i < input.length; i++) {
// Test each character against the "allChar" regex (readable characters).
if (allChar.test(input[i])) {
return i // Return the index of the first non-readable character
}
}
return 0 // Return -1 if no non-readable characters are found
}