i have a string like this for example: 09223-2993/120029
i need to replace the - and / using regex
how can i do this ?
this is what i made, work replacing - , but i cant find a way to reaplce /:
var test = $("#myvalue").val().split("");
for(var i=0; i < test.length; i++) {
test[i] = test[i].replace(/-/g, '');
}
value2 = test.join("" );
alert(value2);
Thanks.
You are really close, all you need to do is add
/to your regexYou should just be able to do this:
since
-is not special to regex, to use the/escape it with a backslash as above, or place it inside of[]to mean a character class.