How to replace all backslashes in a string with a pipe in JavaScript

1 Answer

0 votes
let str = 'javascript\\c\\c++\\';

str = str.replaceAll('\\', '|');

console.log(str);
    
    
    
    
/*
run:
    
"javascript|c|c++|"
    
*/

 



answered Jul 2, 2022 by avibootz

Related questions

1 answer 114 views
1 answer 124 views
1 answer 118 views
1 answer 122 views
2 answers 409 views
1 answer 133 views
...