Backends: Add helper to extract prefixes from glob patterns.