in reply to Regex logic
X[^XH]*H[^HD]*D [download]
By the way, the non greedy modifier is deceptively complex and you'll have better luck by avoiding it.