问题:我正在尝试用空格替换回车符。所以我有以下内容:
txt="This is a beautiful day!<BR>"
response.write(Replace(txt,"<BR>"," "))
我希望<BR>
替换为空格。原因是跟随字符串,我会在字符串后面有文本。所以喜欢:
txt Blah Blah Easter Day!
我也尝试了以下内容:
<%Dim auth As String = "Reason"
Dim txt As String = " You may contact your provider for detailed information about your diagnosis or treatment. This could include the detailed codes and their meanings."
auth = auth.Replace("<BR>", " ")
Dim txt1 As String = auth + txt
Response.Write(txt1)
%>
原因是包含文字后跟<BR>
的字段。我想通过使用replace
我可以删除它而不更新字段(我不想这样做)。相反,会发生以下情况:
Blah blah blah.
You may contact your provider....
我如何实现:
Blah blah blah. You may contact your provider....
任何帮助都将不胜感激。
答案 0 :(得分:1)
你的功能看起来正确;它应该删除<br>
。但是,在文本行的末尾可能还有一个Visual Basic换行符。尝试在当前replace
函数下添加此函数以删除该换行符(如果存在):
auth = auth.Replace(VbCrLf, "")
为了完整起见,您还可以添加以下内容:
auth = auth.Replace(VbCr, "")
auth = auth.Replace(VbLf, "")
答案 1 :(得分:0)
我在这里错过了什么吗?
Dim txt = "This is a beautiful day!<BR>"
txt = txt.Replace("<BR>", " ")
MessageBox.Show(txt)