How to get a specific word from textfile using Regex ?

  • Thread starter Thread starter Mostafa Salaheldien
  • Start date Start date
M

Mostafa Salaheldien

Guest
hello everone,

i want to get only the first word between " " from the texfile it will be here Mahmud

[[["Mahmud","Махмуд"



this is my code

Dim ofd As New OpenFileDialog With {
.Title = "Select Text files",
.Filter = "Text Files (*.txt)|*.txt",
.FilterIndex = 0,
.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyComputer),
.Multiselect = True}

If ofd.ShowDialog = System.Windows.Forms.DialogResult.OK Then
For Each filename As String In ofd.FileNames

Dim reader As New System.IO.StreamReader(filename)
Dim text As String = reader.ReadToEnd()
reader.Close()
Dim regex1 As Regex = New Regex(" "".*\s*")
Dim match As Match = regex1.Match(text)
If match.Success Then
TextBox2.Text = match.ToString
End If
Next
End If

Continue reading...
 
Back
Top