Checking if a line in a file contains user.Handle and '-r'+any single digit number The title pretty much explains everything. I'm try to check if a line in a file contains user.Handle and '-r'+any single digit number, AND that the aforementioned user.Handle does not contain '-r'. I'm sure there is an easier way to do this. And I'm sorry if this made your eyes bleed.

if (line.Contains(user.Handle) &amp;&amp; !user.Handle.Contains("-r") &amp;&amp;
line.Contains("-r1") || line.Contains(user.Handle) &amp;&amp;
!user.Handle.Contains("-r") &amp;&amp; line.Contains("-r2") ||
line.Contains(user.Handle) &amp;&amp; !user.Handle.Contains("-r") &amp;&amp;
line.Contains("-r3") || line.Contains(user.Handle) &amp;&amp;
!user.Handle.Contains("-r") &amp;&amp; line.Contains("-r4") ||
line.Contains(user.Handle) &amp;&amp; !user.Handle.Contains("-r") &amp;&amp;
line.Contains("-r5") || line.Contains(user.Handle) &amp;&amp;
!user.Handle.Contains("-r") &amp;&amp; line.Contains("-r6") ||
line.Contains(user.Handle) &amp;&amp; !user.Handle.Contains("-r") &amp;&amp;
line.Contains("-r7") || line.Contains(user.Handle) &amp;&amp;
!user.Handle.Contains("-r") &amp;&amp; line.Contains("-r8") ||
line.Contains(user.Handle) &amp;&amp; !user.Handle.Contains("-r") &amp;&amp;
line.Contains("-r9"))
If I see it correctly, you could already simplify your code by saying

if (line.Contains(user.Handle) &amp;&amp; !user.Handle.Contains("-r") &amp;&amp;
    (line.Contains("-r1") || line.Contains("-r2") || ... line.Contains("-r9"))


That should be basically the same thing as the above. Now when you look at the last part, you could simplify it to a regular expression -r\d (not sure if - needs to be escaped here) So the final version could look like this:

if (line.Contains(user.Handle) &amp;&amp; !user.Handle.Contains("-r") &amp;&amp;
    Regex.IsMatch(line, "-r\\d"))


did I get your question? Did I miss anything?