Поиск слова после указанного символа
I have a text file that contains several words ........... ........... dimension="13.7mm" row="30" speed="13.4" ........ I want to extract the value 13.7mm This is what I have done //loaded the file string file = "c:\\temp\\myTextFile.txt"; string searchText = "dimension="; //Declare reader as a new StreamReader with file as the file to use StreamReader reader = StreamReader(file); //Declare text as the reader reading to the end String text = reader.ReadToEnd(); //If the searchText is a match if (Regex.IsMatch(text, searchText)) { MessageBox.Show("found it"); //OK now that I found the word 'dimension=" //how to display the next characters between the next " and " //the number of characters may vary (e.g. 125.7mm) }
Что я уже пробовал:
пытался его расколоть
sring[] lines = Regex.Split("server=", " "); foreach (string line in lines) { listBox1.Items.Add(line); }
j snooze
есть ли в текстовом файле более 1 измерения= и вы должны найти их все? в противном случае вы должны быть в состоянии получить начальную позицию "dimension=", а затем получить следующие 2 позиции двойной кавычки, начиная с dimension=, используя методы indexof и substr.
Karthik_Mahalingam
разместите несколько строк текстового файла.