I get a text with JavaScript and sent it by ajax, but I want to remove all the slash that the string can bring as such and replace it with "-"
Text that captures in the information variable: Send data to CE / SE to the person in charge /// Juan or to the person in charge //// pedro
var str = información;
var res = str.replace("/", "-");
alert(res);
With the previous method it would show this: Send data to CE-SE to the person in charge /// Juan or to the person in charge //// pedro
It only works when there is a clear slash, in the method I asked for that, but I could not do a method to remove all the slash and replace it with "-" if I import the amount of slash, that is my problem and it would be very repetitive to do this
var str = información;
var res = str.replace("///", "-");
alert(res);
var str = información;
var res = str.replace("/", "-");
alert(res);
var str = información;
var res = str.replace("////", "-");
alert(res);
Sensing the amount, I do not want to do that if not a method that can do everything regardless of the amount of slash and change them by "-"