All I needed was to expel every single forward and backward slashes slice in a string utilizing Javascript.

Remove Forward Slashes (/) Using JavaScript Function

function FSlash(str) {
  const r = /\/+/gm;
  while (r.test(str)) str = str.replace(r, "");
  return str;
}
//Usage Using Variable
var nx = "4x/4/4/5/6/7//532///45/";
//Call Variable Into Function Name
document.write(FSlash(nx));

Demo : CodePen

The vital part of removing forward slashes from string to note here is the consistent articulation /\\//gm.

Remove Backward Slashes (\) Using JavaScript Function

function BSlash(str) {
  const r = /\\|\\+/gm;
  while (r.test(str)) str = str.replace(r, "");
  return str;
}
//Usage Using Variable
var nx = "Dev : \\D\\i\\m\\a\\s\\Www.webmanajemen.com";
//Call Variable Into Function Name
document.write(BSlash(nx));

Demo : Codepen

The vital part of removing backward slashes from string to note here is the consistent articulation /\\|\\+/gm.

Remove All Slashes Using Combined Javascript Function

function RSlash(str) {
  return BSlash(FSlash(str));
}
// usage
const strex = "4x/4/4/5/6/7//532///45/ Dev: d\\i\\m\\a\\s www.webmanajemen.com";
// call variable into function name
document.write(RSlash(strex));

Demo : Codepen

Full Demo Removing Slashes

See the Pen Remove slashes from string JS by dimas lanjaka (@dimaslanjaka) on CodePen.

Conclusion

The bit of the string you need supplanting is composed between the first and last forward cuts – so on the off chance that you needed the word ‘work area’ supplanted you would compose/work area/g.

As the character we need to expel is an uncommon case you need to escape it utilizing an oblique punctuation line, generally the code will read the twofold forward cut as a remark thus quit preparing the line.

At last, the g implies apply the substitution internationally to the string with the goal that all occasions of the substring are supplanted.

JS Javascript Function Remove Slash From String | WMI - /2017/12/js-javascript-function-remove-slash/cover.jpg

so an article about “JS Function Remove Slash From String” today. I hope this helps.