Monday, July 2, 2012

Trim and Replace multiple string in Javascript

Using following Javascript sysntax you can replace forward slashes (‘/’) with backward slashes (‘\’) :

var strReplace = “C:\Temp\Temp1\Temp2\text.jpeg“;

strReplace = strReplace.replace(new RegExp(/\\/g),”/”);

/////////////////

function ltrim(str){
return str.replace(/^\s+/, '');
}
function rtrim(str) {
return str.replace(/\s+$/, '');
}
function alltrim(str) {
return str.replace(/^\s+|\s+$/g, '');
}

No comments:

Post a Comment