Dicarboxylic Acid Separation by Dynamic and Size-Matched Recognition in Solution and in the Solid State