我正在尝试使用正则表达式捕获xml文档中两个标记之间的一系列标记,但它捕获文档中的每个匹配项。
<Mods>
<unsignedlong>123456</unsignedlong>
</Mods>
<Administrators>
<unsignedlong>12345678910111213</unsignedlong>
</Administrators>
<Banned>
<unsignedlong>12345678910111213</unsignedlong>
</Banned>
这是我需要从中获取以下内容的代码。
<unsignedlong>12345678910111213</unsignedlong>
我一直在使用
<unsignedLong>(?<ModID>\d+)</unsignedLong>
但是这会返回整个文件中的所有值 - 我需要一个字符串来从
中挑出unsigned longs <Mods></Mods>
修改
这适用于识别正则表达式的Web应用程序
答案 0 :(得分:0)
这应该做你需要的几个修改:
SELECT T1.`post_id`,
T1.`category`,
T1.`author_id`,
T1.`title`,
T1.`article`,
T1.`time`
FROM
blog_post T1
INNER JOIN
(SELECT MAX(`time`) AS `time`,`category` FROM blog_post GROUP BY category) T2
ON T1.`category` = T2.`category` AND T1.`time` = T2.`time`
ORDER BY T1.`time` DESC
要匹配您想要的匹配,请使用:
// Match a Regex and Do Stuff
public void showMatch(string input, string expr)
{
MatchCollection mc = Regex.Matches(input, expr);
// Index
int num = 0;
// "For each match in the match collection, Do this"
foreach (Match m in mc)
{
string tm = m.ToString();
num++;
if (num == 1)
{
// Do Stuff if 1 match.
}
if (num == 2)
{
// Do Stuff if 2 matches.
}