View Full Version : Replace str which has comma with spaces, asp
giselle2008
01-10-2008, 01:08 AM
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:
codeexploiter
01-10-2008, 03:30 AM
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.
<script type="text/vbscript">
dim txt
txt="This,is,a,beautiful,day,!"
document.write(txt &"<br/>")
str = Replace(txt,","," ")
document.write(str)
</script>
The above code will replace all the occurrences of comma with space.
Syntax of Replce
Replace(string,find,replacewith[,start[,count[,compare]]]) (http://www.w3schools.com/vbscript/func_replace.asp)
shnawer
01-29-2008, 07:03 PM
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
dsagrera
02-24-2008, 01:03 PM
The Replace function you should use is:
Replace(str, ",", " ", 1)
That will replace each instance of the comma with an space. Regards!
giselle2008
02-29-2008, 03:36 PM
thank you..problem solve..thanx alot
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.