Maybe have two cases:
For the (matched keyword) case, something like this: https://serverfault.com/questions/729232/reg-exp-for-url-in-haproxy
For the (random routing) case, something like: https://www.haproxy.com/blog/haproxy-configuration-basics-load-balance-your-servers
I am a little confused on your question, though. It sounds like you maybe want 3 cases? Can you try wording it differently?