Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/273.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#将项目符号字符转换为HTML无序列表_C#_Regex - Fatal编程技术网

C#将项目符号字符转换为HTML无序列表

C#将项目符号字符转换为HTML无序列表,c#,regex,C#,Regex,需要用更大字符串中的HTML ul&li标记替换文本项目符号“•”。列表始终位于字符串的末尾 我需要将其转换为: "The 2008 <strong>Ford F-350</strong> Super Duty XL is powered by a 5.four-liter V8 engine combined with a six-speed manual transmission. A 6.4-liter diesel and 6.8-

需要用更大字符串中的HTML ul&li标记替换文本项目符号“•”。列表始终位于字符串的末尾

我需要将其转换为:

"The 2008 <strong>Ford F-350</strong> Super Duty XL is powered by a 5.four-liter V8 engine combined with a six-speed manual transmission. A 6.4-liter diesel and 6.8-liter gasoline-powered V10 are also available. Automatics are optional. The Super Duty XL is available in regular, Crew Cab and Super Crew styles and in two- and four-wheel drive.  • ABS is standard for safe, secure stopping power • The front seat is full bench, with recline • Optional packages include a power group and other groups to fit your various needs" 
这是:

"The 2008 <strong>Ford F-350</strong> Super Duty XLT is powered by a 5.4-liter V8 engine combined with a six-speed manual transmission. A 6.4-liter Power Stroke diesel engine and a 6.8-liter V10 are also available, as is a five-speed automatic transmission. The XLT contains all XL content plus chrome exterior trim, premium sound and upgraded seating. • Premium audio includes AM/FM stereo, single-CD/MP3 player and four speakers • Front and rear bumpers and grille surround are chrome for enhanced appearance • Remote keyless entry and perimeter antitheft alarm are standard for increased safety and security "
"The 2008 &lt;strong&gt;Ford F-350&lt;/strong&gt; Super Duty XLT is powered by a 5.4-liter V8 engine combined with a six-speed manual transmission. A 6.4-liter Power Stroke diesel engine and a 6.8-liter V10 are also available, as is a five-speed automatic transmission. The XLT contains all XL content plus chrome exterior trim, premium sound and upgraded seating. <ul><li>Premium audio includes AM/FM stereo, single-CD/MP3 player and four speakers</li><li>Front and rear bumpers and grille surround are chrome for enhanced appearance</li><li>Remote keyless entry and perimeter antitheft alarm are standard for increased safety and security</li></ul>"
为此:

"The 2008 &lt;strong&gt;Ford F-350&lt;/strong&gt; Super Duty XL is powered by a 5.four-liter V8 engine combined with a six-speed manual transmission. A 6.4-liter diesel and 6.8-liter gasoline-powered V10 are also available. Automatics are optional. The Super Duty XL is available in regular, Crew Cab and Super Crew styles and in two- and four-wheel drive.  <ul><li>ABS is standard for safe, secure stopping power</li><li>The front seat is full bench, with recline</li><li>Optional packages include a power group and other groups to fit your various needs</li></ul>"
“2008年strongFord F-350/strong Super Duty XL由5.4升V8发动机和六速手动变速箱组成。还提供6.4升柴油和6.8升汽油动力的V10。自动装置是可选的。Super Duty XL有普通驾驶室、双人驾驶室和超级双人驾驶风格,以及两轮和四轮驱动
  • ABS是安全、可靠制动力的标准配置
  • 前排座椅为全长椅,带倾角
  • 可选套装包括一个动力总成和其他总成,以满足您的各种需求
这是:

"The 2008 &lt;strong&gt;Ford F-350&lt;/strong&gt; Super Duty XLT is powered by a 5.4-liter V8 engine combined with a six-speed manual transmission. A 6.4-liter Power Stroke diesel engine and a 6.8-liter V10 are also available, as is a five-speed automatic transmission. The XLT contains all XL content plus chrome exterior trim, premium sound and upgraded seating. • Premium audio includes AM/FM stereo, single-CD/MP3 player and four speakers • Front and rear bumpers and grille surround are chrome for enhanced appearance • Remote keyless entry and perimeter antitheft alarm are standard for increased safety and security "
"The 2008 &lt;strong&gt;Ford F-350&lt;/strong&gt; Super Duty XLT is powered by a 5.4-liter V8 engine combined with a six-speed manual transmission. A 6.4-liter Power Stroke diesel engine and a 6.8-liter V10 are also available, as is a five-speed automatic transmission. The XLT contains all XL content plus chrome exterior trim, premium sound and upgraded seating. <ul><li>Premium audio includes AM/FM stereo, single-CD/MP3 player and four speakers</li><li>Front and rear bumpers and grille surround are chrome for enhanced appearance</li><li>Remote keyless entry and perimeter antitheft alarm are standard for increased safety and security</li></ul>"
“2008 strongFord F-350/strong Super Duty XLT由5.4升V8发动机和六速手动变速箱组成。一台6.4升动力冲程柴油发动机和一台6.8升V10,以及一台五速自动变速器也可供选择。XLT包含所有XL内容,加上镀铬外饰、高级音响和升级座椅
  • 高级音频包括AM/FM立体声、单CD/MP3播放器和四个扬声器
  • 前后保险杠和格栅环绕物均为镀铬,以增强外观
  • 遥控免匙进入和周边防盗报警器是增强安全性的标准配置

您不需要正则表达式,您可以使用
string.Split
方法拆分
字符上的字符串,然后使用
StringBuilder
在循环中构建HTML

类似于以下的东西应该可以工作(这还没有完全测试-只是粗略的尝试):

//此处,original表示要从中转换的字符串。
string[]splits=original.Split(
新[]{“•”},
StringSplitOptions.RemoveEmptyEntries);
var htmlBuilder=新的StringBuilder();
对于(int i=0;i
  • ”); } else如果(i!=拆分.长度-1) { htmlBuilder.Append(“
  • ”); } } 追加(拆分[i]); } htmlBuilder.Append(“
    • ”);
    不需要正则表达式

  • 附加到字符串
  • “•”
    替换为
    (仅首次出现)
  • “•”
    替换为
  • (所有剩余事件)

  • 好吧,就这样。过度设计FTL。简单多了。谢谢。对不起,杰夫,我从Tomalak第一个开始就接受了他的回答。直到现在才看到你的代码示例。我至少可以试着说我昨晚喝得太多来救我自己吗?我现在正在关闭互联网。@Dzejms:我的回答很简洁。我没有抱怨,只是觉得有趣。:)Tomalak的回答在构建HTML方面简洁而正确——我最初的回答解释了如何做到这一点。我们一起得到了一个完整的答案,我用一些代码拼凑起来。我希望我们大多数时候都能关闭互联网。@Dzejms通常需要说对不起(不是)在此网站上接受一个或另一个答案。:-)