ATC_SIMPLE/BACKEND/app/ultils/helper.ts

15 lines
518 B
TypeScript

/**
* Function to clean up unwanted characters from the output data.
* @param {string} data - The raw data to be cleaned.
* @returns {string} - The cleaned data.
*/
export const cleanData = (data: string) => {
return data
.replace(/--More--\s*BS\s*BS\s*BS\s*BS\s*BS\s*BS/g, '')
.replace(/\s*--More--\s*/g, '')
.replace(/\x1b\[[0-9;]*m/g, '') // Remove ANSI escape codes
.replace(/\x08/g, '')
.replace(/[^\x20-\x7E\r\n]/g, '') // Remove non-printable characters
// .replace(/\r\n/g, '\n')
}