How do i trim down a string[] with - 3 letters??
-
Hi i trying to search for values in .txt file and return the existings lines But how can i trim down the string[] Chunk to -3 letters?? for example: .txt file look like this # k441122 blabla blabla blabla blabla if i search for k441 than return the k441122 with all the existings lines? i have tryade Chunk.Substring(0 , 4) Any idea?? My code look like this: private bool ReadChunk(StreamReader sr, out string[] Chunk, string MatchData) { Chunk = new string[9]; bool FoundMatch = false; for (int i = 0; i < 9; i++) { try { Chunk[i] = sr.ReadLine(); if (i == 1 && Chunk[i] == MatchData) { FoundMatch = true; } } catch (Exception ex) { FoundMatch = false; } } return FoundMatch; } Big Tnx!!
-
Hi i trying to search for values in .txt file and return the existings lines But how can i trim down the string[] Chunk to -3 letters?? for example: .txt file look like this # k441122 blabla blabla blabla blabla if i search for k441 than return the k441122 with all the existings lines? i have tryade Chunk.Substring(0 , 4) Any idea?? My code look like this: private bool ReadChunk(StreamReader sr, out string[] Chunk, string MatchData) { Chunk = new string[9]; bool FoundMatch = false; for (int i = 0; i < 9; i++) { try { Chunk[i] = sr.ReadLine(); if (i == 1 && Chunk[i] == MatchData) { FoundMatch = true; } } catch (Exception ex) { FoundMatch = false; } } return FoundMatch; } Big Tnx!!
Use Regex.
if (Regex.IsMatch(szStringToSearch, szPatternToFind, RegexOptions.IgnoreCase)) { MessageBox.Show("Success"); }
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo