TextBox2 has this kind of text:
Wohnort:Schweiz Entfernung:690 km Beruf:Ingenieurswesen How to copy the word Schweiz после Wohnort , чтобы в TextBox1 so было только слово Schweiz` appears in TextBox1?
Update
I did not understand your question, but I just need to move the text to something like this:
string Town = TextBox2.Text;//TextBox2.Text Ячейка со всей информацией Town = Town.Substring(Town.IndexOf("Wohnort:"));// Нужные мне данные находяться после этого слова. Town = Town.Remove(Town.IndexOf("Entfernung:"));// Это слово я поставил для того чтобы мне в нужную ячейку не закидывал всё что после.. Town = Town.Replace("Wohnort:", ""); //Удаляю Начальное слово чтобы тоже не попадало в нужную мне ячейку TextBox1.Text = (Town); but sometimes the word "Entfernung:" may be missing and be Something else. So it must be somehow different.
All this works for me, I showed how, But I Am sure that all this can be written more simply in three lines, something like:
string Town = TextBox2.Text; Town.Substring(Town.IndexOf("Wohnort:")); Town = Town.ХЗ(Town.Хз("[^ ]Мать его Одно Слово до пробела")) Any thoughts?
Answer:
You wrote that you get the text in TextBox2 using regular expressions, add some kind of character to the end of each found result, say “_” you will get an expression of this kind:
Wohnort:Schweiz__ Entfernung:690 km__ Beruf:Ingenieurswesen__ And now you can turn your action in this way.
string Town = TextBox2.Text; Town = Town.Substring(Town.IndexOf("Wohnort:")); Town = Town.Replace("Wohnort:", ""); TextBox1.Text = Town.Remove(Town.IndexOf("_")); Now it doesn't matter if your second word is from
Town = Town.Remove(Town.IndexOf("Entfernung:")); or some other you have a symbol from which to make a start.
but in this way:
if (userinformbox.Text.Contains("Wohnort:")) { string Town = TextBox2.Text;; Town = Town.Substring(Town.IndexOf("Wohnort:")); Town = Town.Replace("Wohnort:", ""); TextBox1.Text; = Town.Remove(Town.IndexOf("_")); } It doesn't even matter to you whether the position in question will be at all, if not, go to the next one. If you have any questions, write, how can I help. ----------
ВОТ ТАК ВОТ ("Вашу " + "Cами дальше додумывайте кого"); ------------------------
TextBox1is relevant to the point? - VladD