Извлечь текст из listbox1 после определенного текста ?
Hello everyone, This below is a code that extracts everything from listBox1 after "sometext" in textBox1.text, and it works well. private void extract() { string s = string.Join(Environment.NewLine, listBox1.SelectedItems.OfType<object>().Select(i => Regex.Match(i.ToString(), @"sametext?(.*?)(?=#|$)").Groups[1].Value)); textBox1.Text = (s.ToString()); } "sometext" is not always the same. I would like to replace "sametext" with textBox2.text textBox2.Text = different text I tried:
Что я уже пробовал:
private void extract() { string s = string.Join(Environment.NewLine, listBox1.SelectedItems.OfType<object>().Select(i => Regex.Match(i.ToString(), "@"+ textBox2.Text + "?(.*?)(?=#|$)").Groups[1].Value)); textBox1.Text = (s.ToString()); } But it does not work. Please help me. Thank you.