I have a file. Each line is as follows:
[00000] 0xD176234F81150469: foo
I am trying to do this if the string contains a specific substring, I want to extract everything that is to the right of the found substring. For example, if I were looking for 0xD176234F81150469: in the line above, it would return foo . Each line has a variable length. I am using C #.
As a note, each line in the file looks like above, with the base-16 number enclosed in square brackets on the left, followed by a hexadecimal hash and a semicolon, and then an English string.
How can i do this?
Edit
Here is my code:
private void button1_Click(object sender, EventArgs e) { Form1 box = new Form1(); if(MessageBox.Show("This process may take a little while as we loop through all the books.", "Confirm?", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { XDocument doc = XDocument.Load(@"C:\Users\****\Desktop\books.xml"); var Titles = doc.Descendants("Title"); List<string> list = new List<string>(); foreach(var Title in Titles) { string searchstr = Title.Parent.Name.ToString(); string val = Title.Value; string has = @"Gameplay/Excel/Books/" + searchstr + @":" + val; ulong hash = FNV64.GetHash(has); var hash2 = string.Format("0x{0:X}", hash); list.Add(val + " (" + hash2 + ")");
I also repeated every line of the file, adding it to list<> . I must have accidentally deleted this while trying to suggest. Also, I am very new to C #. The main thing I came across is a coincidence.
source share