本帖最后由 josxhn 于 2010-10-25 15:14:31 编辑

解决方案 »

  1.   

    Regex reg = new Regex(@"(?i)<_xxxx>\s*<_tttt[^>]*>([^<]*)</_pppp>([^<]*)</_pppp>");
    MatchCollection mc = reg.Matches("");
     foreach (Match m in mc)
      {
      Console.WriteLine(m.Groups[0].ToString() );
      }
      

  2.   

    string[] result = Regex.Split("文本段1<_xxxx>文本段2<_tttt>文本段3<_pppp>文本段4", "<[^<>]*>");
    foreach (string item in result)
    {
        Console.WriteLine(item);
    }输出
    文本段1
    文本段2
    文本段3
    文本段4
      

  3.   

    (?i)<_xxxx>\s*<_tttt[^>]*>([^<]*)</_pppp>([^<]*)</_pppp>
      正则...
        可是我不会。 
      

  4.   


    大概看懂了[^>][^<]是排除<_ .... ><_ ... >的情况,但是还有问题:
    1.<_ 后面跟的内容是不确定的,可能包含英文,数字,中文,空格,下划线等一切可用作文件名的字符,应该怎么写;
    2.(?i)是标记段落?有什么用?
      

  5.   

    <_[^\.]{1}.{1}[^<>\\\/\:\?\*\"\|]{1,}[^\.]{1}>这样写有没有问题?假设<_后面跟的是文件名,再跟一个>
    [^\.]{1}
    排除.号在首位的情况
    [^<>\\\/\:\?\*\"\|]{1,}
    排除所有文件名中不允许出现的字符,同时也排除了<_...><_...>伪嵌套的可能