How to remove \r\n from string in TypeScript

1 Answer

0 votes
let str: string = "\rabc\n\rdef\ngh\r\n\ri";
 
str = str.replace(/(\r\n|\n|\r)/gm, "");
        
console.log(str);
  
    
     
/*
run:
         
"abcdefghi" 
         
*/
  

 



answered Sep 13, 2024 by avibootz
...