Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to search and replace with my regex.

Status
Not open for further replies.

Xsi

Programmer
May 29, 2015
121
0
0
SE
Hello people,

I have got following string

dim mystring as string ="(1)10002 – Language: ENG-DEU;Reuse: 25;Context Match: 10;Total: 35;Include CM in Reuse: Yes;"

I have made my regex in ultraedit also the regex type is unix.

I want to search for regex below:
Language(.*)\p(.*)\pContext Match(.*)\p(.*)\p(.*)\p


I want to replace with:
Language\1\r\nContext Match\3


Could someone help me with a code that works.

Thank you in advance
 
Code:
[blue]Imports System.Text.RegularExpressions

Module Example
    Public Sub Main()
        Dim input As String = "(1)10002 – Language: ENG-DEU;Reuse: 25;Context Match: 10;Total: 35;Include CM in Reuse: Yes;"
        Dim pattern As String = "(.*)(Language.*);(.*);(Context Match.*);(.*);(.*);"

        MsgBox(Regex.Replace(input, pattern, "$2" & vbCrLf & "$4"))
    End Sub
End Module[/blue]
 
solved by use:

Code:
str = Regex.Replace(str, "Language(.*)\r\n(.*)\r\nContext Match(.*)\r\n(.*)\r\n(.*)\r\n", "Language$1 Context Match$3")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top