Marvin kakuru

Marvin kakuru

  • 1.3k
  • 346
  • 158.3k

txt search

Sep 23 2024 6:45 AM

Hello, i am using the code below to select and display bible verses from a txt. bible file. The code is working, however when i select for example Genesis 1:2 the code returns other verses that begin with two for example 1:20, 21, 22. when i try to apply the \b (word boundary) then the code does not return any data

below is the code am using. any help will be greatly appreciated

textBox4.Text = "";
            int a = System.Convert.ToInt32(txtch.Text);
            int b = System.Convert.ToInt32(txtvs.Text);

            string bibleFilePath = "C:/TextSpeech/Bible.txt";
            string book = txtbook.Text;
            int chapter = a;
            int verse = b;

            
            string searchFor = string.Format(@"{0} {1}:{2}", book, chapter,verse);
            string [] lines = File.ReadAllLines(bibleFilePath,System.Text.Encoding.UTF8);

            foreach (string line in lines)
            {
                if (line.StartsWith(searchFor))
                {
                    textBox4.AppendText(line + Environment.NewLine);
                }
            }


Answers (3)