hi everybody..i need some help.
let say i have one string
"today, i eat, a, bread"
how can i count where is the comma and then i need to replace them with spaces?
is it just use Replace(str,","," ")?
plz help me..thanx :confused:
Printable View
hi everybody..i need some help.
let say i have one string
"today, i eat, a, bread"
how can i count where is the comma and then i need to replace them with spaces?
is it just use Replace(str,","," ")?
plz help me..thanx :confused:
Below mentioned is a piece of client-side script in VBScript (Works only in IE) in which your requirement has been demonstrated. Embed the code in your <head> section and load the page in browser.
The above code will replace all the occurrences of comma with space.Code:<script type="text/vbscript">
dim txt
txt="This,is,a,beautiful,day,!"
document.write(txt &"<br/>")
str = Replace(txt,","," ")
document.write(str)
</script>
Syntax of Replce
Replace(string,find,replacewith[,start[,count[,compare]]])
Remember one thing here in html 2 white spaces means 1 even 100 spaces means one if you want to use commas for 100 blank space use this
StrLine = "Hello,,,,,,,bro,how,,you doing,"
StrLine2 = Replace (strLine, ",", " ",1,-1,1)
Response.Write StrLine2
had one problem if you get 100 commas and it changes it to it can kill your page layout the width would be sooooooooo long in that case use Split Function of VB
Thanks
The Replace function you should use is:
That will replace each instance of the comma with an space. Regards!Code:Replace(str, ",", " ", 1)
thank you..problem solve..thanx alot