Create your of comparer:
class StockSeriesComparer : Comparer<string>
{
public override int Compare(string x, string y)
{
if(x == null && y == null) return 0;
if(x == null) return -1;
if(y == null) return 1;
if(x.Length < y.Length) return -1;
if(x.Length > y.Length) return 1;
return x.CompareTo(y);
}
}
Then you can use it in your comparison like this:
f => comparer.Compare(f, lowerBound) >= 0 && comparer.Compare(f, upperBound) <= 0;
This will work even without stripping the prefixes first, assuming they are all the same.