Note that there are some explanatory texts on larger screens.

plurals
  1. POIn file, if line contains substring, get all of the line from the right
    primarykey
    data
    text
    <p>I have a file. Each line looks like the following:</p> <pre><code>[00000] 0xD176234F81150469: foo </code></pre> <p>What I am attempting to do is, if a line contains a certain substring, I want to extract everything on the <em>right</em> of the substring found. For instance, if I were searching for <code>0xD176234F81150469:</code> in the above line, it would return <code>foo</code>. Each string is of variable length. I am using C#.</p> <p>As a note, every line in the file looks like the above, having a base-16 number enclosed in square brackets on the left, followed by a hexadecimal hash and a semicolon, and an english string afterwards.</p> <p>How could I go about this?</p> <p><strong>Edit</strong></p> <p>Here is my code:</p> <pre><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&lt;string&gt; list = new List&lt;string&gt;(); 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 + ")"); // Sample output: "foo (0xD176234F81150469)" } string[] books = list.ToArray(); File.WriteAllLines(@"C:\Users\****\Desktop\books.txt", books); } else { MessageBox.Show("Aborted.", "Aborted"); } } </code></pre> <p>I also iterated through every line of the file, adding it to a <code>list&lt;&gt;</code>. I must've accidentally deleted this when trying the suggestions. Also, I am very new to C#. The main thing I am getting stumped on is the matching.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload