在 ArrayList 中格式化和替换 和 ,并获取格式化的 ArrayList
本文关键字:格式化 ArrayList 获取 TD TR 替换 | 更新日期: 2023-09-27 17:56:48
由于我无法格式化TD和TR的HTML格式(因为 StackOverflow.com 有一个自动HTML格式化程序,导致编写确切代码的问题,例如TD和TR),所以请考虑以下格式的建议文本:
<tr>
<td>FO Special Added (Comments, Part #, RFQ #) - 13, 13, 13</td>
</tr>
<tr>
<td>FO Special Added (Comments, Part #, RFQ #) - 14, 14, 14</td>
</tr>
我有一个从会话变量填充的数组列表:-
ArrayList ar3 = (ArrayList)Session["arr3"];
Session["arr3"] = "<tr> <td>FO Special Added (Comments, Part #, RFQ #) - 13, 13, 13</td> </tr><tr> <td>FO Special Added (Comments, Part #, RFQ #) - 14, 14, 14</td> </tr><tr> <td>FO Special Added (Comments, Part #, RFQ #) - 15, 15, 15</td> </tr> <td>FO Special Added (Comments, Part #, RFQ #) - 16, 16, 16</td> </tr>
我所要做的就是格式化这个 ArrayList(ar3),这样我就可以在另一个 ArrayList(例如 ResultArList)中拥有从开始 TR 和 TD 开始到关闭 TR 和 TD 结束的各个记录。
然后,此 ResultArList 将用于电子邮件中继和一些纯文本日志(在数据库中创建的自定义表)。
ResultArList应具有以下记录:
结果ArList[0]=FO 特别添加 (注释, 部分 #, RFQ #) - 13, 13, 13
结果ArList[1]=FO 特别添加 (注释, 部分 #, RFQ #) - 14, 14, 14
结果ArList[2]=FO 特别添加(注释,部分 #,RFQ #) - 15, 15, 15
结果ArList[3]=FO 特别添加 (注释, 部分 #, RFQ #) - 16, 16, 16
在 ArrayList ar3 中,这些值的数量是无限的,但上述 HTML 的格式是恒定的。
请帮助我如何自定义格式化我的数组列表并创建一个新的格式化数组列表。
如果我正确理解您的问题,您可以使用正则表达式来提取标签之间的任何内容; 例如:
var regex = new System.Text.RegularExpressions.Regex(@"(?<=<td>).+?(?=</td>)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
var text = "<tr> <td>FO Special Added (Comments, Part #, RFQ #) - 13, 13, 13</td> </tr><tr> <td>FO Special Added (Comments, Part #, RFQ #) - 14, 14, 14</td> </tr><tr> <td>FO Special Added (Comments, Part #, RFQ #) - 15, 15, 15</td> </tr> <td>FO Special Added (Comments, Part #, RFQ #) - 16, 16, 16</td> </tr>";
var matches = regex.Matches(text);
var results = matches.Cast<Match>()
.Select(match => match.Value)
.ToList();
相关文章:
- 如何使用掩码以通用方式格式化字符串值
- 是否可以使用其基类型格式化值
- 带有 Json.Net 格式化程序的通道工厂
- 以编程方式搜索 Word 文档中的格式化文本并用标签括起来
- 用逗号格式化十进制,保留尾随零
- C# ASP arraylist gets cleared
- 格式化 XML 标签
- 如何在不使用字符串 + 的情况下格式化 SQL 查询
- 在 C# 中,有没有一种简单的方法来格式化字符串以包含边距
- 没有媒体类型格式化程序在部署到生产后可供读取
- 字符串格式化程序 c# 中不应输出
- 如果语句突然被 Visual Studio 2010 格式化到下一行
- 在重建时重新锐化器重构/格式化代码,如果插入符号位于字符串末尾,则进行清理
- 通过SQL将属性存储在Arraylist中并显示在文本框中
- 如何以不同的格式格式化日期时间
- 将 C# arraylist.binarysearch 与自定义对象一起使用
- 将 ArrayList 值保存到 XML C#
- 使 Console.WriteLine() 包装器使用额外的格式化参数,如“{0}”
- 如何将 ArrayList 写入文本文件
- 在 ArrayList 中格式化和替换
和 ,并获取格式化的 ArrayList
本文关键字:格式化 ArrayList 获取 TD TR 替换 | 更新日期: 2023-09-27 17:56:48
由于我无法格式化TD和TR的HTML格式(因为 StackOverflow.com 有一个自动HTML格式化程序,导致编写确切代码的问题,例如TD和TR),所以请考虑以下格式的建议文本:
<tr>
<td>FO Special Added (Comments, Part #, RFQ #) - 13, 13, 13</td>
</tr>
<tr>
<td>FO Special Added (Comments, Part #, RFQ #) - 14, 14, 14</td>
</tr>
我有一个从会话变量填充的数组列表:-
ArrayList ar3 = (ArrayList)Session["arr3"];
Session["arr3"] = "<tr> <td>FO Special Added (Comments, Part #, RFQ #) - 13, 13, 13</td> </tr><tr> <td>FO Special Added (Comments, Part #, RFQ #) - 14, 14, 14</td> </tr><tr> <td>FO Special Added (Comments, Part #, RFQ #) - 15, 15, 15</td> </tr> <td>FO Special Added (Comments, Part #, RFQ #) - 16, 16, 16</td> </tr>
我所要做的就是格式化这个 ArrayList(ar3),这样我就可以在另一个 ArrayList(例如 ResultArList)中拥有从开始 TR 和 TD 开始到关闭 TR 和 TD 结束的各个记录。
然后,此 ResultArList 将用于电子邮件中继和一些纯文本日志(在数据库中创建的自定义表)。
ResultArList应具有以下记录:
结果ArList[0]=FO 特别添加 (注释, 部分 #, RFQ #) - 13, 13, 13
结果ArList[1]=FO 特别添加 (注释, 部分 #, RFQ #) - 14, 14, 14
结果ArList[2]=FO 特别添加(注释,部分 #,RFQ #) - 15, 15, 15
结果ArList[3]=FO 特别添加 (注释, 部分 #, RFQ #) - 16, 16, 16
在 ArrayList ar3 中,这些值的数量是无限的,但上述 HTML 的格式是恒定的。
请帮助我如何自定义格式化我的数组列表并创建一个新的格式化数组列表。
如果我正确理解您的问题,您可以使用正则表达式来提取标签之间的任何内容; 例如:
var regex = new System.Text.RegularExpressions.Regex(@"(?<=<td>).+?(?=</td>)", RegexOptions.Compiled | RegexOptions.IgnoreCase);
var text = "<tr> <td>FO Special Added (Comments, Part #, RFQ #) - 13, 13, 13</td> </tr><tr> <td>FO Special Added (Comments, Part #, RFQ #) - 14, 14, 14</td> </tr><tr> <td>FO Special Added (Comments, Part #, RFQ #) - 15, 15, 15</td> </tr> <td>FO Special Added (Comments, Part #, RFQ #) - 16, 16, 16</td> </tr>";
var matches = regex.Matches(text);
var results = matches.Cast<Match>()
.Select(match => match.Value)
.ToList();
相关文章:
- 如何使用掩码以通用方式格式化字符串值
- 是否可以使用其基类型格式化值
- 带有 Json.Net 格式化程序的通道工厂
- 以编程方式搜索 Word 文档中的格式化文本并用标签括起来
- 用逗号格式化十进制,保留尾随零
- C# ASP arraylist gets cleared
- 格式化 XML 标签
- 如何在不使用字符串 + 的情况下格式化 SQL 查询
- 在 C# 中,有没有一种简单的方法来格式化字符串以包含边距
- 没有媒体类型格式化程序在部署到生产后可供读取
- 字符串格式化程序 c# 中不应输出
- 如果语句突然被 Visual Studio 2010 格式化到下一行
- 在重建时重新锐化器重构/格式化代码,如果插入符号位于字符串末尾,则进行清理
- 通过SQL将属性存储在Arraylist中并显示在文本框中
- 如何以不同的格式格式化日期时间
- 将 C# arraylist.binarysearch 与自定义对象一起使用
- 将 ArrayList 值保存到 XML C#
- 使 Console.WriteLine() 包装器使用额外的格式化参数,如“{0}”
- 如何将 ArrayList 写入文本文件
- 在 ArrayList 中格式化和替换
和 ,并获取格式化的 ArrayList