title: How to check if two command line are equal?
body: <p>I have the following two commandline/run process:</p>
  <pre><code>string x = @&quot;&quot;&quot;C:\Users\Bob\AppData\Local\Microsoft\OneDrive\OneDrive.exe&quot;&quot; /background&quot;
  string y = @&quot;&quot;&quot;C:\Users\Alice\AppData\Local\Microsoft\OneDrive\OneDrive.exe&quot;&quot; /background&quot;
  </code></pre>
  <p>We know that the command is the same, but we cannot use the <code>CompareTo</code> because it will fail (due to the different username). Following a piece of advice given to me as an answer to another question of mine, I've used the following code:</p>
  <pre><code>private static int ComputeDistance(string s, string t)
          {
              s = s.ToLower();
              t = t.ToLower();
              int n = s.Length;
              int m = t.Length;
              int[,] distance = new int[n + 1, m + 1];
              int cost = 0;
              if (n == 0) return m;
              if (m == 0) return n;
              for (int i = 0; i &lt;= n; distance[i, 0] = i++) ;
              for (int j = 0; j &lt;= m; distance[0, j] = j++) ;
              for (int i = 1; i &lt;= n; i++)
              {
                  for (int j = 1; j &lt;= m; j++)
                  {
                      cost = (t.Substring(j - 1, 1) ==
                          s.Substring(i - 1, 1) ? 0 : 1);
                      distance[i, j] = Math.Min(Math.Min(distance[i - 1, j] + 1,
                      distance[i, j - 1] + 1), distance[i - 1, j - 1] + cost);
                  }
              }
              return distance[n, m];
          }
  
  public static float GetSimilarity(string string1, string string2)
          {
              float dis = ComputeDistance(string1, string2);
              float maxLen = string1.Length;
              if (maxLen &lt; string2.Length)
                  maxLen = string2.Length;
              if (maxLen == 0.0F)
                  return 1.0F;
              else
                  return 1.0F - dis / maxLen;
          }
  </code></pre>
  <p>Use: <code>Console.WriteLine(100 * MyClass.GetSimilarity(x, y));</code></p>
  <p>The two given commandline match: <code>93,33334</code>. And this is ok. But I have so many false positives! (match greather than <code>75%</code> - established by me). For example:</p>
  <pre><code>string x =  @&quot;&quot;&quot;C:\Users\Bob\Desktop\Directory\1.exe&quot;&quot; -p -s&quot;;
  string y = @&quot;&quot;&quot;C:\Users\Alice\Desktop\Directory\2.exe&quot;&quot; -W&quot;;
  </code></pre>
  <p>match: <code>77,27273%</code>. But the process and commands aren't the same!</p>
  <p>Do you think I should do substring match (separated by <code>\</code>) for path and match one to one with the command (after the <code>-</code> or <code>--</code>, ecc.) or there is a better way?</p>