2016-05-21 7 views

Antwort

1

Bist du für diese Suche:

foreach(string line in richTextBox1.Lines) 
     { 
      if(line.Contains("MY_STRING")) 
      { 
       //my logic 
       // the variable line is a string containing the your entire text in that line 
      } 
     } 
+0

schließen, so etwas wie 'foreach (var Linie in richTextBox1.Lines) {Vielleicht if (line.Contains ("my_string")) { string text = // erhalten den gesamten Text auf Linie } } ' –

+0

@MinecraftSquadFactionsPVP was sonst? : P –

+0

Ersetze // meine Logik mit etwas wie 'string value = // line.GetAllText' –

0

mit regulären Ausdrücken Sie es unabhängig von der Textquelle tun könnte :

foreach(Match m in Regex.Matches(richTextBox1.Text, $"^(?:.*?)?{word}(?:.*?)?$", RegexOptions.Multiline)) 
{ 
    //do it here 
    //the line string is m.Value 
} 
Verwandte Themen