ACL based on incoming URI value

Hi Folks,

Currently I’m in need of route the traffic based on incoming URI Value…

For Example, below is the incoming URI value
http://myexample.domain/profile/A123456P9876/history

In this, A123456P9876 value from the above URI, I need to capture the 123456 which is in between of A & P & then I need to make ACL to forward to particular backends based on the manipulated number

I’m fine in setting the header after taking 123456 & capture the header and write ACL also, but I need someway to achieve this.

Is this possible in any way… Please help me

Thanks,
Vel