export function EscapeStringRegexp(string: string) { if (typeof string !== "string") { throw new TypeError("Expected a string"); } // Escape characters with special meaning either inside or outside character sets. // Use a simple backslash escape when it's always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns' stricter grammar. return string.replace(/[|\\{}()[\]^$+*?.]/gu, "\\$&").replace(/-/gu, "\\x2d"); } export function IsRecord(maybeRecord: unknown): maybeRecord is Record { return typeof maybeRecord === "object" && maybeRecord !== null; } export function IsHexadecimalString(s: string): boolean { return /^[0-9a-f]+$/iu.test(s); }