Sha*_*had 1 c# regex stringbuilder
我在创建自己的论坛.引用消息时遇到问题.我知道如何在文本框中添加引用消息,但我无法弄清楚如何在发布后从字符串中提取值.在文本框中我有这样的事情:
[quote IdPost=8] Some quoting text [/quote]
[quote IdPost=15] Second quoting text [/quote]
Run Code Online (Sandbox Code Playgroud)
你能说出发布表格后从字符串中提取所有"IdPost"号码的最简单方法吗?
通过使用正则表达式
@"\[quote IdPost=(\d+)\]"
Run Code Online (Sandbox Code Playgroud)
就像是
Regex reg = new Regex(@"\[quote IdPost=(\d+)\]");
foreach (Match match in reg.Matches(text))
{
...
}
Run Code Online (Sandbox Code Playgroud)