// java.lang.String as FILIUS's text formats use it - each differs from its // JavaScript namesake. /** `String.trim()`: every UTF-16 unit up to U+0020 off both ends. */ export function javaTrim(text: string): string { return text.replace(/^[\u0000-\u0020]+|[\u0000-\u0020]+$/g, ''); } /** * `text.split(separator)` for a one-character separator: trailing empty * parts are dropped — "a;b;;".split(";") is two parts, ";;" none — but a * text without the separator is one part, even the empty text. */ export function javaSplit(text: string, separator: string): string[] { if (!text.includes(separator)) return [text]; const parts = text.split(separator); while (parts.length > 0 && parts[parts.length - 1] === '') parts.pop(); return parts; }