Tuesday, 3 May 2016

How to replace double backslash('\\') using substring function in java script

I am describe ,how to use substring of string and replace the specific characters from strings. In below image, show sql server database table ,  Bloodpressure column contains backslash that is 120\80 .











When fetch record from sql then in c# programming language that contains double back slash 120\\80. In server side that automatically add double backslash "\\".



In below image, I am using String function that is convert Blood Pressure to java script Object that,s contain in index format. In next step ,I am using substring function that first part is 0 means it extract from beginning of string and second part using indexOf function that find the element of index then first part get the value 120 from backslash and in next step using replace function to replace the string upperpart value and "\\" from string with "" then we get next part of backslash.


var str=new String(param.BloodPressure);
var Upperpart=str.substring(0,str.indexOf('\\'));
var Lowerpart=str.replace(Upperpart + "\\","");








No comments:

Post a Comment