期望输出结果 -
Hi
Hello
U There...
当前输出 -
Hi Hello U there...
使用replace方法与
<br/>
标签仅适用于换行。然而,我需要保留U和There之间的空格。有人能提供解决方案吗?
你尝试过为每个空格使用
吗?
补充@Jon Skeet的答案,使用正则表达式将空格替换为 。
string s1 = "He saw a cute\tdog.";
Regex r = new Regex(@"\s+");
string s3 = r.Replace(s1, " ");
string s3 = r.Replace(s1, " ");
- Rajeev在 HTML 中只需添加 null 例如:
<html>
<body>
<select>
<optgroup label="Swedish Cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup >// get a space between
<optgroup label="German Cars">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>
protected void TextBox1_TextChanged(object sender, EventArgs e)
{
string sos = "";
if (TextBox1.Text == sos)
{
TextBox1.Text = "00";
}
char opo = TextBox1.Text[0];
char opo1 = TextBox1.Text[1];
Label1.Text = (opo + " " + opo1);
}
输入到文本框的文本 = 23 输出到标签的文本 = 2 3