name/content-code [size]123/32131-123123 [55]123/32131-123123/-[]  分开条件
/-  分开条件[]可有可无上面三个是条件我拿出我写的,不知道对不对。求一个正确管用的!.*/.*-(\[*.*\]*)*

解决方案 »

  1.   

    分别拿出 name /   content -code ([size])可以不出现!
      

  2.   

    dddddddddddddd
    可以用split()这个方法把这几个分别获取出来!!!
      

  3.   

    (?<name>\d*)\/(?<content>\d*[-]\d*)\s*(\[(?<size>\d*)\]){0,1}
      

  4.   


            Dim str As String = "123/32131-123123 [55]"
            Dim r As New System.Text.RegularExpressions.Regex("(?<name>\d*)\/(?<content>\d*[-]\d*)\s*(\[(?<size>\d*)\]){0,1}")        Dim mc As System.Text.RegularExpressions.MatchCollection = r.Matches(str)
            For i As Integer = 0 To mc.Count - 1
                MsgBox(mc(i).Value)
                MsgBox(mc(i).Groups("name").Value)
                MsgBox(mc(i).Groups("content").Value)
                If mc(i).Groups.Count > 2 Then
                    MsgBox(mc(i).Groups("size").Value)
                End If
            Next
      

  5.   


                string str = @"name/content-code [size]123/32131-123123 [55]123/32131-123123 ";
                foreach (Match match in Regex.Matches(str, @"(?<name>[^\/]*)\/(?<content>[^\-]*)\-(?<code>[^\[]*)\s*\[(?<size>.*)\]|(?<name>[^\/]*)\/(?<content>[^\-]*)\-(?<code>[^\[]*)"))
                {
                    Console.Write(match.Groups["name"].Value + " " + match.Groups["content"].Value + " " + match.Groups["code"].Value + " " + match.Groups["size"].Value);
                    Console.WriteLine();
                }
    /*输出
    name content code  size
    123 32131 123123  55
    123 32131 123123
    */
      

  6.   

    (?<name>[^/]*)|((?<=\/)(?<hen>[^-]*))