I was using regexp_filter to do replacements in a client selection that is powered by sphinx. I tried to make the regexp more efficient so instead of
regexp_filter=Dr(.)? Jones=>Doctor Louis
regexp_filter=Dr(.)? Smith=>Doctor Alban
I did
regexp_filter=(?i)Dr(.)? (Jones|Smith)=>Doctor \2
However this gives me unexpected results, specifically that 'Dr Jobes' returns all Dr X
records (e.g. Dr Jones
, Doctor Gleason
, Dr Proctor
).
As I saw it however each record in the table with Dr X
would simply have indexed Dr to Doctor with the last name (\2) intact. Instead it seems to map whatever term I put in the (A|B)
pipe into a generic match.
This seems inconsistent with how this approach has worked in the past, wondering if I am missing something obvious in the regexp.
BTW if I test this in myregextester it works as expected: