(\w+)([<>])(\w+)([<>])(\w+)替换为:\1\2\3 and \3\4\5

解决方案 »

  1.   

    str1<str2>str3 
    str1<str2>str3 
    str1<str2>str3 
    str1<str2>str3 
    ==>str1<str2 and str2>str3 
    str1<str2 and str2>str3 
    str1<str2 and str2>str3 
    str1<str2 and str2>str3 
      

  2.   

    Dim s As String = Console.ReadLine()        Dim r As Regex = New Regex("^(?<1>\w+)(?<2>[<>])(?<3>\w+)(?<4>[<>])(?<5>\w+)$")
            Dim m As Match = r.Match(s)
            If m.Success() Then
                Console.WriteLine(m.Groups("1").Value & m.Groups("2").Value & m.Groups("3").Value & "      " & m.Groups("3").Value & m.Groups("4").Value & m.Groups("5").Value)
            Else
                Console.WriteLine("err")        End If
            Console.ReadLine()
    输入
    1<5>3              =========>1<5   5>3
    str1>str2<str3    ==========> str1>str2 和 str2<str3
      

  3.   

    Dim s As String = Console.ReadLine()Dim r As Regex = New Regex("^(?<1>\w+)(?<2>[<>])(?<3>\w+)(?<4>[<>])(?<5>\w+)$")
    Dim m As Match = r.Match(s)
        If m.Success() Then
             Console.WriteLine(m.Groups("1").Value & m.Groups("2").Value & m.Groups("3").Value & "和" & m.Groups("3").Value & m.Groups("4").Value & m.Groups("5").Value)
       Else
        Console.WriteLine("err")   End If
        Console.ReadLine()
    输入
    1<5>3              =========>1<5和5>3
    str1>str2<str3     =========>str1>str2 和 str2<str3