The solution is:
protected static CQ GetElementByIdPattern(CQ doc, string contains)
{
string select = string.Format("*[id*={0}]", contains);
return doc.Select(select).First();
}
Based on the jQuery syntax: $('[id=contains]: first')